[Bug c/51294] spurious warning from -Wconversion in C and C++ in conditional expressions
tortoise_74 at yahoo dot co.uk
gcc-bugzilla@gcc.gnu.org
Thu Nov 24 17:58:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51294
--- Comment #4 from Bruce Adams <tortoise_74 at yahoo dot co.uk> 2011-11-24 17:09:56 UTC ---
Shouldn't integral conversion rules apply if the types of the second and third
arguments to a conditional expression differ.
So zero should be converted from the default int to a char as presumably the
older version of gcc did.
Perhaps a language lawyer could explain why this is or isn't a bug.
Though obviously warnings are not covered by the standard.
Note:
(haveBar?bar_:(char)0)
is not an acceptable workaround for C++ if -Wold-style-cast is used (which is
in my experience typical). It would have to be
(haveBar?bar_:static_cast<char>(0))
which is a notch higher in annoyingness.
More information about the Gcc-bugs
mailing list