1827819 Members
1888 Online
109969 Solutions
New Discussion

aCC enum bug

 

aCC enum bug

aCC 3.57 fails to compile this code, which is valid C++ and compiles with gcc, MSVC*, and more.

---

class A {
};

class B {
enum {
A,
C = A
};
};

---

Error 24: "main.cpp", line 7 # '' expected instead of 'A'.
C = A
^
Error 216: "main.cpp", line 8 # Integer constant expected in enumerator initialization.
};
^
3 REPLIES 3
Peter Godron
Honored Contributor

Re: aCC enum bug

Andreas,
I have only ever seen either:
enum{A,C};
or
enum{A,C=4);
After compiling your code in gcc, what happens at that statement,if you run it?

aCC may not let you compile because it could generate an invalid condition.

Re: aCC enum bug

Enum values can always take the value of other enum values. This is commonly used in API design when an enum entry needs to be renamed, yet keep the same value. The condition is not invalid.

enum {
A,
B,
C = A // Value = 0.
};

This is also what happens when compiling it. C = A is the same as C = 0. aCC cannot compile this code; it's a bug in aCC :-).
Dennis Handly
Acclaimed Contributor

Re: aCC enum bug

Andreas is right, it is a bug.
It works fine with aCC6 and with A.03.67, PHSS_34414

It is CR JAGae88844: Error 24 Unable to distinguish b/w tentative class and enum constant