From: Shriramana Sharma <samjnaa@gmail.com>
To: Steve Graegert <graegerts@gmail.com>
Cc: Linux C Programming List <linux-c-programming@vger.kernel.org>
Subject: Re: enum types and casting
Date: Thu, 17 May 2007 00:07:58 +0530 [thread overview]
Message-ID: <464B4F86.80709@gmail.com> (raw)
In-Reply-To: <6a00c8d50705040518o2712d37cw8db39d80a20f3b4e@mail.gmail.com>
Steve Graegert wrote:
> To convert an integral type to an enumeration, use the following semantic:
>
> enum TEST { zero = 0, one, two };
> int i1 = 2;
> test t1 = static_cast<TEST> (i1); // t1 == two
Steve,
I tried this as follows:
enum BODY { SUN, MOON, STAR } ;
enum PLANET { EARTH, VENUS, MARS, PLUTO } ;
int main ( void )
{
BODY body ;
body = static_cast < BODY > ( 3 ) ; // does not give error.
body = static_cast < BODY > ( PLUTO ) ; // does not give error.
}
but it still does not throw an error even though the enum being casted
*to* does not contain an identifier equivalent to the value actually
being casted, whether a primitive integer or an identifier belonging to
another enum.
Don't you think this is a GCC bug?
Shriramana.
prev parent reply other threads:[~2007-05-16 18:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-29 5:40 enum types and casting Shriramana Sharma
2007-05-04 11:26 ` leslie.polzer
2007-05-04 12:18 ` Steve Graegert
2007-05-16 18:37 ` Shriramana Sharma [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=464B4F86.80709@gmail.com \
--to=samjnaa@gmail.com \
--cc=graegerts@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.