Suspicious warning with ?:
Owen Taylor
owt1@cornell.edu
Sat Feb 14 09:13:00 GMT 1998
The following code:
==============
int bar();
long foo () {
unsigned long i;
return bar() ? i : -1;
}
==============
Which compiles without complaint with both gcc and g++ from
gcc-2.7.2.3, and when compiled with gcc from egcs-1.0.1,
gives a warning when compiled with g++ from egcs-1.0.1.
===========
$ g++ -c questwarn.cc
questwarn.cc: In function `long int foo()':
questwarn.cc:6: warning: converting of negative value `-1' to `long unsigned int
$ g++ -v
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.23/specs
gcc version egcs-2.90.23 980102 (egcs-1.0.1 release)
===========
Perhaps its just a misunderstanding on my part, but its hard to
understand why the '-1' would be converted to unsigned here.
(The system is Linux 2.0.33, glibc-2.0.5c)
Regards,
Owen Taylor
More information about the Gcc-bugs
mailing list