------- Comment #6 from pluto at agmk dot net  2007-01-23 15:02 -------
(In reply to comment #5)
> I don't get this. The enum value can be any integer apart from foo and bar.

3.9.1/7, subnote. 43) says that enum isn't an integral type
but can be promoted to {signed/unsigned} int/long.

an assignment of int to enum produces an error,
so how ( in defined non-hax0r way ) enum can be any integer?
if it can be, then what's difference between enum and int?


$ cat tmp.cpp
typedef enum { foo, bar } e;
e assign( int v__ )  { return v__; }
int promote( e e__ ) { return e__; }

$ x86_64-gnu-linux-g++ tmp.cpp -O2 -c -Wall
tmp.cpp: In function 'e assign(int)':
tmp.cpp:2: error: invalid conversion from 'int' to 'e'


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28236

Reply via email to