This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/51294] spurious warning from -Wconversion in C and C++ in conditional expressions
- From: "tortoise_74 at yahoo dot co.uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 24 Nov 2011 17:09:56 +0000
- Subject: [Bug c/51294] spurious warning from -Wconversion in C and C++ in conditional expressions
- Auto-submitted: auto-generated
- References: <bug-51294-4@http.gcc.gnu.org/bugzilla/>
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.