Article View: comp.std.c
Article #4169enums - unsigned ok?
From: Peter Seebach
Date: Tue, 03 Oct 1995 20:48
Date: Tue, 03 Oct 1995 20:48
19 lines
819 bytes
819 bytes
Under gcc-2.7.0 (Sparc, SunOS 4.1.4)
#include <stdio.h>
enum { FOO, BAR };
main() {
printf("%d\n", BAR * -1);
}
prints 2^32-1 or so. ANSI 6.5.2.2, Semantics, says "the identifiers in an
enumerator list are declared as constants that have type /int/ and may
appear wherever such are permitted."
I read this to say that enums may not act unsigned.
Can anyone confirm? (Or suggest a workaround...)
(Yes, I know this sample program has undefined termination status.)
-s
Technical Details
Message-ID:
<44s7jj$p2l@mangrove.Intran.Xerox.COM>Path:
arc1-ca.pugleaf.net!mangrove.Intran.Xerox.COM!not-for-mailShow Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!mangrove.Intran.Xerox.COM!not-for-mail From: seebs@mangrove.Intran.Xerox.COM (Peter Seebach) Subject: enums - unsigned ok? Message-ID: <44s7jj$p2l@mangrove.Intran.Xerox.COM> Sender: news@news.wrc.xerox.com Organization: Xerox Intran Operations Date: Tue, 3 Oct 1995 20:48:51 GMT