RE: [sv-bc] Enum proposal uploaded

From: Steven Sharp <sharp_at_.....>
Date: Fri May 08 2009 - 12:09:26 PDT
>From: "Bresticker, Shalom" <shalom.bresticker@intel.com>

>How do the auto-increment and duplicate value checking work? I assume on the 
post-cast values.


Yes.

For the auto-increment, the LRM says

"A name without a value is automatically assigned an increment of the
value of the previous name.  It shall be an error to automatically
increment the maximum representable value of the enum."

The value of the name is the value after the cast.

The text of the duplicate value check says

"Both the enumeration names and their integer values shall be unique.
It shall be an error to set two values to the same name or to set the
same value to two names, regardless of whether the values are set
explicitly or by automatic incrementing."

This may be a little less obvious, but is still talking about the value
that the name is set to, which is the value after the cast.  (Part of
why I find this wording less obvious is that it talks about setting a
value to a name, where the assignment syntax and my mental image are
of setting the name to a value.  If it said "setting two names to the
same value", or even "giving the same value two names", that would seem
more natural to me.)

The only place that operates with the pre-cast value is the evaluation of
the expression and the check for truncation during the cast.  Everything
else operates with the value corresponding to the name (set to the name,
or that the name is set to), which is the value after the cast.

Steven Sharp
sharp@cadence.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri May 8 12:10:22 2009

This archive was generated by hypermail 2.1.8 : Fri May 08 2009 - 12:11:08 PDT