This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/51294] spurious warning from -Wconversion in C and C++ in conditional expressions


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]