Opened 4 years ago

Last modified 4 years ago

#46 assigned defect

Enum constants are lvalues

Reported by: Rob Schluntz Owned by: Rob Schluntz
Priority: minor Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description (last modified by Rob Schluntz)

Enum constants are currently lvalues, making for a cheap conversion to reference. Because of this, & operators are added incorrectly, causing gcc errors.

My first instinct was to say that all enum VariableExprs are non-lvalues, but of course this doesn't work since actual enum variables are lvalues. This will require a more nuanced approach, but I think the basic idea is right.

Example that causes an error:

enum E {
  val
};

int main() {
  E x[3];
  3 ? x[2] : val;
}

Change History (1)

comment:1 Changed 4 years ago by Rob Schluntz

Description: modified (diff)
Note: See TracTickets for help on using tickets.