Open
Description
Setting a typeof(type-name)
in an enumeration fixed underlying type is broken: an error is raised explaining that the identifiers are not declared, but we're in the process of declaring them. The bug is present in clang 20.1.0. GCC 15.1 doesn't have this bug.
See C23 6.7.3.6.p4 Typeof specifiers
If the
typeof
operators are applied to an expression, they yield the type of their operand. Otherwise, they designate the same type as the type name with any nestedtypeof
specifier evaluated.
Interestingly, typeof(expression)
isn't broken!
https://gcc.godbolt.org/z/TGWYdhndo
enum e : int {
E = 0,
};
enum f : typeof(int) {
F = 0, /* error: use of undeclared identifier 'F' */
};
int g = 0;
enum g : typeof(g) {
G = 0,
};
int main() {}
<source>:6:5: error: use of undeclared identifier 'F'
6 | F = 0,
| ^
1 error generated.
Compiler returned: 1