[Bug c/51294] spurious warning from -Wconversion in C and C++
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Nov 24 12:45:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51294
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-11-24 12:01:49 UTC ---
(In reply to comment #0)
> 0 is a const so the compiler should be able to choose the correct type.
0 is an int, so the compiler is required by the standard to make the
conditional expression (haveBar?bar_:0) have type int.
It shouldn't warn though, as the conversion from int to char won't alter the
value.
> The workaround is either to disable the warning with -Wno-conversion or add
> unecessary constants as below. I don't think this is acceptable.
Or (haveBar?bar_:(char)0)
More information about the Gcc-bugs
mailing list