pedantic Wall

John Love-Jensen eljay@adobe.com
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
---foo.cpp---
enum Foo { kBar = ~0LL; };
enum Baz { kQuux = ~0L; };
---eof---

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.

MY QUESTION...
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'; };

Thanks,
--Eljay



More information about the Gcc-help mailing list