RE: [sv-bc] 4.10.4 "Enumerated types in numerical expressions" - unclearness

From: Steven Sharp <sharp_at_.....>
Date: Tue Nov 01 2005 - 13:00:35 PST
>From: "Bresticker, Shalom" <shalom.bresticker@intel.com>

>You seem to be saying that, for example, in 4.10, where medal4 is
>declared as "enum bit[3:0]", then if medal4 is used in an expression,
>then it is cast to regular non-enum type "bit[3:0]".

Yes.


>But then, strictly speaking, the example at the bottom of p. 25 in
>4.10.3, "c = green;" would mean that "green" would be cast to type int,
>bringing us back to "c = 1;", which is illegal.

Yes, this was sloppy wording, since even a simple identifier is an
expression.


>So I guess that case is to be excluded, and it should be interpreted to
>mean an enum variable or enum identifier which is operated on by some
>operator.

Pretty much, yes.  Although assignment to a non-enum could also be
considered to cause an implicit cast to the base type before the assign.


>Now, is this any different from what 4.10.3 says,
>"enumerated variables are auto-cast into integral values", or is it the
>same idea written more fully?

I assume it is the same concept.


>Still unclear is the part about,
>"(either explicitly or using int as the default)."
>
>The intent seems to refer to the declaration of the enum base type
>within the enum declaration.
>
>However, the English grammar makes it seem mean,
>"An enum variable or identifier used as part of an expression is
>automatically cast, either explicitly or using int as the default, to
>the base type of the enum declaration."
>
>That is, it seems to refer to the automatic casting, which does not seem
>to be the intent.

More bad wording.  I think it is referring to the case where the base
type was not explicitly declared, but defaulted to int.

So I think the intent was to mean,
"An enum variable or identifier used as part of an expression is
automatically cast to the base type of the enum declaration (which
was either explicitly declared or used int as the default)."

But that parenthetical remark is unnecessary.  The enum is cast to the
base type.  There is no need to unclearly describe the rules for how
the base type was determined.  The exact rules are already defined
elsewhere.


Steven Sharp
sharp@cadence.com
Received on Tue Nov 1 13:00:54 2005

This archive was generated by hypermail 2.1.8 : Tue Nov 01 2005 - 13:02:21 PST