[sv-bc] clarification on rules for enums

From: Paul Graham <pgraham_at_.....>
Date: Mon Sep 19 2005 - 13:47:35 PDT
In p1800 draft 6 section 4.10 on enumeration types defines
error conditions which apply to enum literals that lack an
explicit value specifier.  It is an error if incrementing
causes a value overflow.  It is also an error if such a
literal has a value which is used by another literal in the
same type declaration.  The way the spec is worded, it
appears that these errors don't apply to explicitly
initialized enums.  Is this true?

      // error: blue overflows
    enum bit [1:0] {red, orange, yellow, green, blue } color;

      // no error, blue is explicitly initialized
      // except that now blue (truncated to 2 bits) matches red
    enum bit [1:0] {red, orange, yellow, green, blue = 4} color;

      // no error, blue is explicitly initialized, so is red
    enum bit [1:0] {red = 0, orange, yellow, green, blue = 4} color;

      // no error, blue is explicitly initialized, so is red
    enum bit [1:0] {red = 0, orange, yellow, green, blue = 0} color;

Paul
Received on Mon Sep 19 13:47:37 2005

This archive was generated by hypermail 2.1.8 : Mon Sep 19 2005 - 13:47:46 PDT