mangling enum literals
Alain Miniussi
alainm at cup.hp.com
Wed Apr 12 18:09:02 UTC 2000
Daveed Vandevoorde wrote:
>
> Alex Samuel wrote:
> >
> > The paragraph discussing literal template arguments doesn't mention
> > enumeral values. Do we use the value's <source-name>, or numerical
> > representation in the underlying type?
>
> I think you need to use the numerical value, because some valid enum
> values may not have a name. E.g., I believe that with:
>
> enum E { e1 = 1, e2 = 100 };
>
> ((E)3) is a valid constant-expression of type E.
>
> (From memory; I didn't check the standard.)
7.2 - Enumeration declarations [dcl.enum]
6- For an enumeration where emin is the smallest enumerator
and emax is the largest, the values of the enumeration
are the values of the underlying type in the range bmin
to bmax, where bmin and bmax are, respectively, the
smallest and largest values of the smallest bit-field
that can store emin and emax.
-9- An expression of arithmetic or enumeration type
can be converted to an enumeration type explicitly.
The value is unchanged if it is in the range of enumeration
values of the enumeration type; otherwise the resulting
enumeration value is unspecified.
5.2.9 - Static cast [expr.static.cast]
-7- A value of integral type can be explicitly converted
to an enumeration type. The value is unchanged if the
integral value is within the range of the enumeration
values (dcl.enum). Otherwise, the resulting enumeration
value is unspecified.
Alain
More information about the cxx-abi-dev
mailing list