Prohibit enum <-> int mixup
Jonathan Wakely
jwakely.gcc@gmail.com
Sat Jan 29 22:35:00 GMT 2011
On 29 January 2011 20:48, Enrico Weigelt wrote:
>
> I'm using C++. It already warns me about a few things, eg. missing
> case's in switch statements. But it still accepts assigning
> enum to int and vice versa.
No it doesn't, C++ allows enums to be assigned to ints but not the
other way around.
enum e { val };
e var = 0;
e.cc:2: error: invalid conversion from ‘int’ to ‘e’
More information about the Gcc-help
mailing list