pedantic Wall

John Love-Jensen
Fri Oct 18 05:27:00 GMT 2002

Hi everybody,

I expect to see two warnings and/or errors for the following code:

g++ -c -pedantic -Wall foo.cpp
enum Foo { kBar = ~0LL; };
enum Baz { kQuux = ~0L; };

GCC 3.2 20020818 (prerelease) complains about line one "ISO C89 forbids long
long integer constants".  Complains, but does the "forbidden" thing... doing
what I asked for, regardless of ISO C89.

I was expecting to see a warning about using a long int in line two.  As per
C++PL by Stroustrup, section 4.8.

Am I to take it that if sizeof(int) == sizeof(long), then everything is
a-okay for the long int enum values?

On the platform I'm compiling on, Cygwin for WinNT, sizeof(int) ==
sizeof(long) == 4.

Ahh, I remember back when I used SAS/C++ 6.56 (Amiga), where one could use
the language extension (more-or-less, I may have gotten the syntax jumbled)
for explicit enum storage sizes:
char enum Fred { kBarney = 'x'; };


More information about the Gcc-help mailing list