Sample code:
enum E : char;
enum E;
Invocations:
$ g -std=c 14 -pedantic -Wall -Wextra -c
<nothing>
$ clang -std=c 14 -pedantic -Wall -Wextra -c
<source>:2:6: error: enumeration previously declared with fixed underlying type
$ icc -std=c 14 -pedantic -Wall -Wextra -c
<nothing>
$ cl /std:c 14 /Za
<source>(2): error C3432: 'E': a forward declaration of an unscoped enumeration must have an underlying type
<source>(2): error C3433: 'E': all declarations of an enumeration must have the same underlying type, was 'char' now 'int'
Is this code well-formed?
What the standard says?
CodePudding user response:
From [dcl.enum]/3:
An unscoped enumeration shall not be later redeclared as scoped and each redeclaration shall include an enum-base specifying the same underlying type as in the original declaration.
Emphasis added. Clang is correct.
