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]

g++ 2.96 -W issues bogus warning for conditional expression with enum and unsigned


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;
}

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