This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/28236] wrong "control reaches" warning with enums.
- From: "pluto at agmk dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jan 2007 15:02:26 -0000
- Subject: [Bug c++/28236] wrong "control reaches" warning with enums.
- References: <bug-28236-7667@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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