<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH 7 of 9] Fix comparison signedness warning



On Fri, Aug 06, 2010 at 11:49:24PM +0200, Vincent Lefevre wrote:
On 2010-08-06 23:33:29 +0200, Matthias Andree wrote:
-    if (chunk >= sizeof (buf))
+    if ((size_t)chunk >= sizeof (buf))

I would say that a signedness warning would be here a compiler bug
since with a simple variable range analysis, one can deduce that
chunk is non-negative. With such a cast, you may hide a real bug
if the context changes, e.g. because a better compiler would no
longer be able to emit a warning.

FYI, GCC 4.4.5 doesn't have this problem.

xvii:~/software/mutt/mutt> make pop_lib.o
gcc -DPKGDATADIR=\"/home/vinc17/share/mutt\" -DSYSCONFDIR=\"/home/vinc17/etc\" 
-DDOTLOCK_PATH=\"/usr/bin/mutt_dotlock\" -DMUTTLOCALEDIR=\"/home/vinc17/share/locale\" 
-DHAVE_CONFIG_H=1 -I.  -I. -I. -I./imap  -Iintl -I./intl  -Wall -pedantic -Wno-long-long -g -O2 -MT pop_lib.o -MD -MP 
-MF .deps/pop_lib.Tpo -c -o pop_lib.o pop_lib.c
mv -f .deps/pop_lib.Tpo .deps/pop_lib.Po

gcc 4.4.3 w/ -Wextra does emit this error. I think that is the difference you are seeing.

me

Attachment: pgpO1skoE4AqW.pgp
Description: PGP signature