Does GCC assign any type to enums that can be specified in an assignment operator?

John Love-Jensen eljay@adobe.com
Mon Jun 25 12:41:00 GMT 2007


Hi Michael,

The type for the enum, as given, will be signed int.

Now if you want the enum to be ambiguous, you can do something like this:

enum { Uno = -1, Dos, Tres = 0x80000000 };

That will cause an ambiguous overload of the signed & unsigned assignment
operators, since the 0x80000000 will be taken to be an unsigned int as per
the standard C/C++ interpretation rules.  (Assuming a 32-bit int platform.)

Is that the situation you are running into?

You can "fix" it by doing:

enum { Uno = -1, Dos, Tres = int(0x80000000) };

--Eljay



More information about the Gcc-help mailing list