This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Warning about int<-->enum conversions?


Nicholas Nethercote wrote:

> I'm seeing conflicting responses about the legality of these
> conversions: 

>> No, because this is a kind of integer promotion which is allowed by
>> the standard ([conv.prom]/2), so there is nothing wrong about it.
>> Converting the other way (int -> enum) is instead forbidden and
>> should be rejected by GCC. 
> 
> 
> On Thu, 8 Jul 2004, Gabriel Dos Reis wrote:
> 
>> In C, you can have both implicit conversions. C++ says that you
>> can't go from int to enums implicitly
> 
> Who's right?  Hmm... maybe you both are, I didn't actually specify
> whether this was C or C++ (it was meant to be C).

There is no conflict. I assumed C++ for some reason, so we both agree.

Giovanni Bajo



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]