[LLVMbugs] [Bug 9000] enums are classified as unsigned ints instead of signed ones

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jan 18 10:47:59 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9000

Douglas Gregor <dgregor at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dgregor at apple.com
         Resolution|                            |INVALID

--- Comment #1 from Douglas Gregor <dgregor at apple.com> 2011-01-18 12:47:58 CST ---
This is behaving correctly per C99 6.7.2.2p2, which allows the implementation
to pick char or any signed or unsigned integer type as the underlying type. GCC
and Clang pick "unsigned int" (which is fine), which ends up promoting to
itself.

In C++, it promotes to an int.

See Clang's test/CodeGen/enum.c for a fun example where C and C++ produce
different results because of the different promotion rules.

Because of the (admittedly weird) behavior of C, this warning is not spurious:
z really is treated as an unsigned value, and that can both be surprising and
lead to bugs if the programmer doesn't understand it.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list