With gcc < 13, mixing old __attribute__ keyword and C++11 [[ ]] attribute can create some error.
To reproduce, we can compile the following code snippet on godbot:
class [[gnu::visibility ("default")]] [[deprecated]] SomeClass1
{};
class [[gnu::visibility ("default"), deprecated]] SomeClass2
{};
class __attribute__((visibility ("default"))) __attribute__((deprecated)) SomeClass3
{};
class __attribute__((visibility ("default"))) [[deprecated]] SomeClass4
{};
int main()
{
SomeClass1 c1;
SomeClass2 c2;
SomeClass3 c3;
SomeClass4 c4;
}
SomeClass4 will not compile on gcc < 13 with the following error:
<source>:10:47: error: expected identifier before '[' token
10 | class __attribute__((visibility ("default"))) [[deprecated]] SomeClass4
This code build well with clang >= 3.0 when -std=c++11 is activated.
If we remove SomeClass4 and deprecated attribute. This code build with gcc >= 4.8 when -std=c++11 is activated.
deprecated attribute is working fine in gcc >= 5.
With gcc < 13, mixing old
__attribute__
keyword and C++11[[ ]]
attribute can create some error.To reproduce, we can compile the following code snippet on godbot:
SomeClass4
will not compile on gcc < 13 with the following error:This code build well with clang >= 3.0 when
-std=c++11
is activated. If we remove SomeClass4 and deprecated attribute. This code build with gcc >= 4.8 when-std=c++11
is activated. deprecated attribute is working fine in gcc >= 5.bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96117