This is the mail archive of the gcc-help@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]
Other format: [Raw text]

pedantic Wall


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


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