The following code compiles and run with Clang (tested on 13, 14, and current git head), but not with GCC.
struct foo {
int field<0, 1, int, 3>;
};
But I do not understand what it is declaring: what is this field ?
int field<0, 1, int, 3>;
I can put whatever I want in the field<>
template (if it is even a template?), e.g. field<0, 1, int, 3>
compiles and run. But I cannot access it afterwards.
Assuming field
isn't a template that has been declared, the program is ill-formed.
But I do not understand what it is declaring: what is this field ?
Clang AST says:
`-CXXRecordDecl 0xdb6f20 <test.cpp:1:1, line:3:1> line:1:8 struct foo definition
`-FieldDecl 0xdb7168 <line:2:3> col:7 'int'
Clang AST for a program with int field;
:
`-CXXRecordDecl 0x168af90 <test2.cpp:1:1, line:3:1> line:1:8 struct foo definition
`-FieldDecl 0x168b150 <line:2:3, col:7> col:7 field 'int'
So, it looks like Clang thinks that an int
field is being declared, but the name of the field is empty. This seems to be corroborated by being able to initialise this "unnamed" field:
foo f{0}; // compiles in Clang
The first Clang version to have this bug seems to be 9: https://gcc.godbolt.org/z/d386oz8v8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With