This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++ 2.96 -W issues bogus warning for conditional expression with enum and unsigned
- To: gcc bug reports <gcc-bugs at gcc dot gnu dot org>
- Subject: g++ 2.96 -W issues bogus warning for conditional expression with enum and unsigned
- From: Martin Sebor <sebor at roguewave dot com>
- Date: Tue, 04 Jul 2000 23:01:00 -0600
- Organization: Rogue Wave Software, Inc.
Hi,
the program below issues a warning when compiled with gcc -W. This new
warning (it was not present in 2.95.2) disappears if the type of the
third subexpression is int.
I don't see a reason for the warning in 5.16, p6. In particular, bullet
2 says: "The second and third operands have arithmetic or enumeration
type; the usual arithmetic conversions are performed to bring them to a
common type, and the result is of that type." The usual arithmetic
conversion would in this case be a conversion to unsigned int according
to 4.5, p2. Am I missing something?
Thanks
Martin
PS Also, the text of the warning is unnecessarily broken up into two
lines.
$ gcc -W t.cpp
t.cpp: In function `int main (int)':
t.cpp:5: warning: enumeral and non-enumeral type in conditional
expression
$ cat t.cpp
int main ()
{
enum { e };
return e ? e : 0U;
}