This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Warning about int<-->enum conversions?
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: "Nicholas Nethercote" <njn25 at cam dot ac dot uk>,"Gabriel Dos Reis" <gdr at acm dot org>
- Cc: "Robert Dewar" <dewar at gnat dot com>,<gcc at gcc dot gnu dot org>
- Date: Thu, 8 Jul 2004 19:38:24 +0200
- Subject: Re: Warning about int<-->enum conversions?
- References: <20040708142931.CB6B1F2EBC@nile.gnat.com><32810.::ffff:128.194.146.36.1089297660.squirrel@webmail.nerim.net> <Pine.LNX.4.60.0407081548130.30153@hermes-1.csi.cam.ac.uk>
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