Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use c++11 attribute when C++11 is activated #725

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

jorisv
Copy link
Contributor

@jorisv jorisv commented Oct 31, 2024

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.

bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96117

@jorisv jorisv marked this pull request as draft October 31, 2024 10:05
@jorisv jorisv self-assigned this Oct 31, 2024
@jorisv jorisv marked this pull request as ready for review October 31, 2024 14:37
@jorisv
Copy link
Contributor Author

jorisv commented Oct 31, 2024

Tested in stack-of-tasks/pinocchio#2469

@jorisv jorisv merged commit 03d9537 into jrl-umi3218:master Nov 5, 2024
2 checks passed
@jorisv jorisv deleted the topic/modern_attribute branch November 5, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants