RE: [sv-bc] Some query related with enum.

From: Steven Sharp <sharp_at_.....>
Date: Mon Aug 25 2008 - 12:54:06 PDT
As Shalom pointed out, cases 2, 3 and 4 are clearly illegal because they
assign two different enum constants the same value.  Regardless of the
signedness of the expression used to represent the value, the final value
of the bit pattern for two of the constants is the same.  The two values
cannot be distinguished.

The issue of the values being outside the representable range is less
clear.  Does this include values that change meaning based on whether
they are regarded as signed or unsigned?  Or does it only include values
that lose significant bits due to truncation?  The LRM does not say.

Case 4 is illegal regardless of your interpretation.  The value is signed
and the enum is signed, and for a signed number, truncation of 3 to 2 bits
loses a significant bit: the sign bit in the truncated result does not
match the original sign bit.

Cases 2 and 3 do not do any truncation, so they cannot be losing any
significant bits.  Only the interpretation of the bit pattern changes when
it is regarded as signed rather than unsigned.  I don't think the LRM text
is clear on whether this is valid or not.

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 Mon Aug 25 12:55:05 2008

This archive was generated by hypermail 2.1.8 : Mon Aug 25 2008 - 12:55:54 PDT