Debian Bug report logs - #528374
standout macro returns unsigned value

version graph

Package: libncurses5-dev; Maintainer for libncurses5-dev is Craig Small <csmall@debian.org>; Source for libncurses5-dev is src:ncurses.

Reported by: Matt Kraai <kraai@ftbfs.org>

Date: Tue, 12 May 2009 13:36:04 UTC

Severity: normal

Tags: patch

Found in version ncurses/5.7+20090510-1

Fixed in version 5.7+20090516-1

Done: Daniel Baumann <daniel@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Daniel Baumann <daniel@debian.org>:
Bug#528374; Package libncurses5-dev. (Tue, 12 May 2009 13:36:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matt Kraai <kraai@ftbfs.org>:
New Bug report received and forwarded. Copy sent to Daniel Baumann <daniel@debian.org>. (Tue, 12 May 2009 13:36:07 GMT) Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Matt Kraai <kraai@ftbfs.org>
To: submit@bugs.debian.org
Subject: standout macro returns unsigned value
Date: Tue, 12 May 2009 06:33:07 -0700
[Message part 1 (text/plain, inline)]
Package: libncurses5-dev
Version: 5.7+20090510-1
Tags: patch

The standout macro expands to

 (((stdscr)->_attrs = (((1UL) << ((8) + 8)))))

If this is compared against ERR, which expands to (-1), and GCC's
-Wsign-compare option is enabled, GCC displays the following warning (or
error, if -Werror is turned on):

 comparison between signed and unsigned

The attached patch fixes this by casting the macro's result to int.

-- 
Matt                                                 http://ftbfs.org/
[cast-wattrset-value-to-int (text/plain, attachment)]

Message sent on to Matt Kraai <kraai@ftbfs.org>:
Bug#528374. (Fri, 15 May 2009 23:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 528374-submitter@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@his.com>
To: Matt Kraai <kraai@ftbfs.org>, 528374-submitter@bugs.debian.org
Subject: Re: Bug#528374: standout macro returns unsigned value
Date: Fri, 15 May 2009 19:44:34 -0400
[Message part 1 (text/plain, inline)]
On Tue, May 12, 2009 at 06:33:07AM -0700, Matt Kraai wrote:
> Package: libncurses5-dev
> Version: 5.7+20090510-1
> Tags: patch
> 
> The standout macro expands to
> 
>  (((stdscr)->_attrs = (((1UL) << ((8) + 8)))))
> 
> If this is compared against ERR, which expands to (-1), and GCC's
> -Wsign-compare option is enabled, GCC displays the following warning (or
> error, if -Werror is turned on):
> 
>  comparison between signed and unsigned

I'm not seeing this warning for g++ 4.3.3 and these options

OPTS="-ansi -pedantic
	-Wall
	-Wmissing-declarations
	-Wshadow
	-Wcast-align
	-Wpointer-arith
	-Wsign-compare"
 
> The attached patch fixes this by casting the macro's result to int.
> 
> -- 
> Matt                                                 http://ftbfs.org/

> diff -ru ncurses-5.7+20090510~/include/curses.h.in ncurses-5.7+20090510/include/curses.h.in
> --- ncurses-5.7+20090510~/include/curses.h.in	2009-05-12 06:28:10.000000000 -0700
> +++ ncurses-5.7+20090510/include/curses.h.in	2009-05-12 06:29:46.000000000 -0700
> @@ -1093,9 +1093,9 @@
>  #if !NCURSES_OPAQUE
>  #if defined(_XOPEN_SOURCE_EXTENDED) && @NCURSES_EXT_COLORS@
>  #define wattrset(win,at)	((win)->_color = PAIR_NUMBER(at), \
> -				 (win)->_attrs = (at))
> +				 ((int)(win)->_attrs = (at))
>  #else
> -#define wattrset(win,at)	((win)->_attrs = (at))
> +#define wattrset(win,at)	((int)((win)->_attrs = (at)))
>  #endif
>  #endif /* NCURSES_OPAQUE */
>  


-- 
Thomas E. Dickey <dickey@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
[signature.asc (application/pgp-signature, inline)]

Message sent on to Matt Kraai <kraai@ftbfs.org>:
Bug#528374. (Sat, 16 May 2009 00:51:02 GMT) Full text and rfc822 format available.

Message #11 received at 528374-submitter@bugs.debian.org (full text, mbox):

From: Matt Kraai <kraai@ftbfs.org>
To: Thomas Dickey <dickey@his.com>
Cc: 528374-submitter@bugs.debian.org
Subject: Re: Bug#528374: standout macro returns unsigned value
Date: Fri, 15 May 2009 17:46:29 -0700
On Fri, May 15, 2009 at 07:44:34PM -0400, Thomas Dickey wrote:
> On Tue, May 12, 2009 at 06:33:07AM -0700, Matt Kraai wrote:
> > The standout macro expands to
> > 
> >  (((stdscr)->_attrs = (((1UL) << ((8) + 8)))))
> > 
> > If this is compared against ERR, which expands to (-1), and GCC's
> > -Wsign-compare option is enabled, GCC displays the following warning (or
> > error, if -Werror is turned on):
> > 
> >  comparison between signed and unsigned
> 
> I'm not seeing this warning for g++ 4.3.3 and these options
> 
> OPTS="-ansi -pedantic
> 	-Wall
> 	-Wmissing-declarations
> 	-Wshadow
> 	-Wcast-align
> 	-Wpointer-arith
> 	-Wsign-compare"

I'm able to reproduce the problem by compiling the following file:

 #include <curses.h>
 
 void
 foo (void)
 {
   standout () == ERR;
 }

with the following command line:

 gcc -Wsign-compare -c foo.c

Here's the output of "gcc -v":

 Using built-in specs.
 Target: i486-linux-gnu
 Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.3-10' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
 Thread model: posix
 gcc version 4.3.3 (Debian 4.3.3-10)

which comes from the Debian gcc-4.3 4.3.3-10 package.

-- 
Matt                                                 http://ftbfs.org/




Message sent on to Matt Kraai <kraai@ftbfs.org>:
Bug#528374. (Sat, 16 May 2009 00:57:12 GMT) Full text and rfc822 format available.

Message #14 received at 528374-submitter@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@his.com>
To: Matt Kraai <kraai@ftbfs.org>
Cc: 528374-submitter@bugs.debian.org
Subject: Re: Bug#528374: standout macro returns unsigned value
Date: Fri, 15 May 2009 20:55:10 -0400 (EDT)
On Fri, 15 May 2009, Matt Kraai wrote:

> On Fri, May 15, 2009 at 07:44:34PM -0400, Thomas Dickey wrote:
>> On Tue, May 12, 2009 at 06:33:07AM -0700, Matt Kraai wrote:
>>> The standout macro expands to
>>>
>>>  (((stdscr)->_attrs = (((1UL) << ((8) + 8)))))
>>>
>>> If this is compared against ERR, which expands to (-1), and GCC's
>>> -Wsign-compare option is enabled, GCC displays the following warning (or
>>> error, if -Werror is turned on):
>>>
>>>  comparison between signed and unsigned
>>
>> I'm not seeing this warning for g++ 4.3.3 and these options
>>
>> OPTS="-ansi -pedantic
>> 	-Wall
>> 	-Wmissing-declarations
>> 	-Wshadow
>> 	-Wcast-align
>> 	-Wpointer-arith
>> 	-Wsign-compare"
>
> I'm able to reproduce the problem by compiling the following file:
>
> #include <curses.h>
>
> void
> foo (void)
> {
>   standout () == ERR;
> }
>
> with the following command line:
>
> gcc -Wsign-compare -c foo.c

thanks (I can reproduce this one).

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net




Information forwarded to debian-bugs-dist@lists.debian.org, Daniel Baumann <daniel@debian.org>:
Bug#528374; Package libncurses5-dev. (Sat, 16 May 2009 01:21:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matt Kraai <kraai@ftbfs.org>:
Extra info received and forwarded to list. Copy sent to Daniel Baumann <daniel@debian.org>. (Sat, 16 May 2009 01:21:03 GMT) Full text and rfc822 format available.

Message #19 received at 528374@bugs.debian.org (full text, mbox):

From: Matt Kraai <kraai@ftbfs.org>
To: Thomas Dickey <dickey@his.com>, 528374@bugs.debian.org
Subject: Re: Bug#528374: standout macro returns unsigned value
Date: Fri, 15 May 2009 18:14:22 -0700
On Fri, May 15, 2009 at 08:55:10PM -0400, Thomas Dickey wrote:
> On Fri, 15 May 2009, Matt Kraai wrote:
>> I'm able to reproduce the problem by compiling the following file:
>>
>> #include <curses.h>
>>
>> void
>> foo (void)
>> {
>>   standout () == ERR;
>> }
>>
>> with the following command line:
>>
>> gcc -Wsign-compare -c foo.c
>
> thanks (I can reproduce this one).

Ah, good.  Sorry, I should have included this information in the
initial report.

-- 
Matt                                                 http://ftbfs.org/




Message sent on to Matt Kraai <kraai@ftbfs.org>:
Bug#528374. (Sat, 16 May 2009 10:00:26 GMT) Full text and rfc822 format available.

Message #22 received at 528374-submitter@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@his.com>
To: Matt Kraai <kraai@ftbfs.org>
Cc: 528374-submitter@bugs.debian.org
Subject: Re: Bug#528374: standout macro returns unsigned value
Date: Sat, 16 May 2009 05:53:38 -0400 (EDT)
On Fri, 15 May 2009, Matt Kraai wrote:

> On Fri, May 15, 2009 at 08:55:10PM -0400, Thomas Dickey wrote:
>> On Fri, 15 May 2009, Matt Kraai wrote:
>>> I'm able to reproduce the problem by compiling the following file:
>>>
>>> #include <curses.h>
>>>
>>> void
>>> foo (void)
>>> {
>>>   standout () == ERR;
>>> }
>>>
>>> with the following command line:
>>>
>>> gcc -Wsign-compare -c foo.c
>>
>> thanks (I can reproduce this one).
>
> Ah, good.  Sorry, I should have included this information in the
> initial report.

well... I was not alert, and did a "man gcc", which seemed to say it
applied to C++ only, and that didn't show the problem.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net




Message sent on to Matt Kraai <kraai@ftbfs.org>:
Bug#528374. (Sat, 16 May 2009 15:21:08 GMT) Full text and rfc822 format available.

Message #25 received at 528374-submitter@bugs.debian.org (full text, mbox):

From: Matt Kraai <kraai@ftbfs.org>
To: Thomas Dickey <dickey@his.com>
Cc: 528374-submitter@bugs.debian.org
Subject: Re: Bug#528374: standout macro returns unsigned value
Date: Sat, 16 May 2009 07:31:44 -0700
On Sat, May 16, 2009 at 05:53:38AM -0400, Thomas Dickey wrote:
> On Fri, 15 May 2009, Matt Kraai wrote:
>
>> On Fri, May 15, 2009 at 08:55:10PM -0400, Thomas Dickey wrote:
>>> On Fri, 15 May 2009, Matt Kraai wrote:
>>>> I'm able to reproduce the problem by compiling the following file:
>>>>
>>>> #include <curses.h>
>>>>
>>>> void
>>>> foo (void)
>>>> {
>>>>   standout () == ERR;
>>>> }
>>>>
>>>> with the following command line:
>>>>
>>>> gcc -Wsign-compare -c foo.c
>>>
>>> thanks (I can reproduce this one).
>>
>> Ah, good.  Sorry, I should have included this information in the
>> initial report.
>
> well... I was not alert, and did a "man gcc", which seemed to say it
> applied to C++ only, and that didn't show the problem.

I guess the GCC manual could be improved then, because I made the same
misunderstanding.  I couldn't understand why a C++-only option would
be causing a problem.

-- 
Matt                                                 http://ftbfs.org/




Information stored :
Bug#528374; Package libncurses5-dev. (Sat, 16 May 2009 22:39:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Thomas Dickey <dickey@his.com>:
Extra info received and filed, but not forwarded. (Sat, 16 May 2009 22:39:02 GMT) Full text and rfc822 format available.

Message #30 received at 528374-quiet@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@his.com>
To: Matt Kraai <kraai@ftbfs.org>, 528374-quiet@bugs.debian.org
Cc: 528374-submitter@bugs.debian.org
Subject: Re: Bug#528374: standout macro returns unsigned value
Date: Sat, 16 May 2009 18:34:29 -0400 (EDT)
On Sat, 16 May 2009, Matt Kraai wrote:

> On Sat, May 16, 2009 at 05:53:38AM -0400, Thomas Dickey wrote:
>> On Fri, 15 May 2009, Matt Kraai wrote:
>>
>>> On Fri, May 15, 2009 at 08:55:10PM -0400, Thomas Dickey wrote:
>>>> On Fri, 15 May 2009, Matt Kraai wrote:
>>>>> I'm able to reproduce the problem by compiling the following file:
>>>>>
>>>>> #include <curses.h>
>>>>>
>>>>> void
>>>>> foo (void)
>>>>> {
>>>>>   standout () == ERR;
>>>>> }
>>>>>
>>>>> with the following command line:
>>>>>
>>>>> gcc -Wsign-compare -c foo.c
>>>>
>>>> thanks (I can reproduce this one).
>>>
>>> Ah, good.  Sorry, I should have included this information in the
>>> initial report.
>>
>> well... I was not alert, and did a "man gcc", which seemed to say it
>> applied to C++ only, and that didn't show the problem.
>
> I guess the GCC manual could be improved then, because I made the same
> misunderstanding.  I couldn't understand why a C++-only option would
> be causing a problem.

agree - I was reading this part:


           -Wall turns on the following warning flags:

           -Waddress -Warray-bounds (only with -O2) -Wc++0x-compat
           -Wchar-subscripts -Wimplicit-int -Wimplicit-function-declaration
           -Wcomment -Wformat -Wmain (only for C/ObjC and unless
           -ffreestanding) -Wmissing-braces -Wnonnull -Wparentheses
           -Wpointer-sign -Wreorder -Wreturn-type -Wsequence-point
           -Wsign-compare (only in C++) -Wstrict-aliasing -Wstrict-overflow=1

Even without that, the message doesn't show up just by adding it to
the other flags I'm using (perhaps a bug), but does show up when adding
it by itself.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net




Message sent on to Matt Kraai <kraai@ftbfs.org>:
Bug#528374. (Sat, 16 May 2009 22:39:03 GMT) Full text and rfc822 format available.

Information stored :
Bug#528374; Package libncurses5-dev. (Sun, 17 May 2009 00:42:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matt Kraai <kraai@ftbfs.org>:
Extra info received and filed, but not forwarded. (Sun, 17 May 2009 00:42:04 GMT) Full text and rfc822 format available.

Message #38 received at 528374-quiet@bugs.debian.org (full text, mbox):

From: Matt Kraai <kraai@ftbfs.org>
To: Thomas Dickey <dickey@his.com>
Cc: 528374-quiet@bugs.debian.org, 528374-submitter@bugs.debian.org
Subject: Re: Bug#528374: standout macro returns unsigned value
Date: Sat, 16 May 2009 17:38:25 -0700
On Sat, May 16, 2009 at 06:34:29PM -0400, Thomas Dickey wrote:
> agree - I was reading this part:
>
>
>            -Wall turns on the following warning flags:
>
>            -Waddress -Warray-bounds (only with -O2) -Wc++0x-compat
>            -Wchar-subscripts -Wimplicit-int -Wimplicit-function-declaration
>            -Wcomment -Wformat -Wmain (only for C/ObjC and unless
>            -ffreestanding) -Wmissing-braces -Wnonnull -Wparentheses
>            -Wpointer-sign -Wreorder -Wreturn-type -Wsequence-point
>            -Wsign-compare (only in C++) -Wstrict-aliasing -Wstrict-overflow=1
>
> Even without that, the message doesn't show up just by adding it to

it = -Wall?

> the other flags I'm using (perhaps a bug), but does show up when adding
> it by itself.

I don't think it's a bug: after I reread the documentation a few times
(and as some quick tests verify), -Wall turns -Wsign-compare on for
C++ programs, whereas -Wextra turns it on for C programs.  I imagine
there's some good reason for this.

-- 
Matt                                                 http://ftbfs.org/




Message sent on to Matt Kraai <kraai@ftbfs.org>:
Bug#528374. (Sun, 17 May 2009 00:42:05 GMT) Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Daniel Baumann <daniel@debian.org>:
Bug#528374; Package libncurses5-dev. (Mon, 24 Aug 2009 00:27:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to dickey@his.com:
Extra info received and forwarded to list. Copy sent to Daniel Baumann <daniel@debian.org>. (Mon, 24 Aug 2009 00:27:04 GMT) Full text and rfc822 format available.

Message #46 received at 528374@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@his.com>
To: 528374@bugs.debian.org
Cc: 528374-submitter@bugs.debian.org
Subject: re: #528374 standout macro returns unsigned value
Date: Sun, 23 Aug 2009 20:16:10 -0400
[Message part 1 (text/plain, inline)]
This was addressed in ncurses' 20090516 patch.

-- 
Thomas E. Dickey <dickey@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
[signature.asc (application/pgp-signature, inline)]

Message sent on to Matt Kraai <kraai@ftbfs.org>:
Bug#528374. (Mon, 24 Aug 2009 00:27:11 GMT) Full text and rfc822 format available.

Reply sent to daniel@debian.org:
You have taken responsibility. (Mon, 24 Aug 2009 11:12:14 GMT) Full text and rfc822 format available.

Notification sent to Matt Kraai <kraai@ftbfs.org>:
Bug acknowledged by developer. (Mon, 24 Aug 2009 11:12:14 GMT) Full text and rfc822 format available.

Message #54 received at 528374-done@bugs.debian.org (full text, mbox):

From: Daniel Baumann <daniel@debian.org>
To: dickey@his.com, 528374-done@bugs.debian.org
Subject: Re: Bug#528374: #528374 standout macro returns unsigned value
Date: Mon, 24 Aug 2009 13:03:11 +0200
Version: 5.7+20090516-1

Thomas Dickey wrote:
> This was addressed in ncurses' 20090516 patch.

closing then, thanks.

-- 
Address:        Daniel Baumann, Burgunderstrasse 3, CH-4562 Biberist
Email:          daniel.baumann@panthera-systems.net
Internet:       http://people.panthera-systems.net/~daniel-baumann/




Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Tue, 22 Sep 2009 07:45:42 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Wed Apr 16 16:17:39 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.