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

C23 thread_local is mapping to C++ thread_local, not C11 _Thread_local #70068

Closed
Fznamznon opened this issue Oct 24, 2023 · 4 comments · Fixed by #70107
Closed

C23 thread_local is mapping to C++ thread_local, not C11 _Thread_local #70068

Fznamznon opened this issue Oct 24, 2023 · 4 comments · Fixed by #70107
Labels
accepts-invalid c23 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party

Comments

@Fznamznon
Copy link
Contributor

Per 6.7.1 p4

In the declaration of an object with block scope, if the declaration specifiers include thread_local,
they shall also include either static or extern.

gcc does complain.

Online demo https://godbolt.org/z/YorncrhKW

cc @AaronBallman

@Fznamznon Fznamznon added c clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 24, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 24, 2023

@llvm/issue-subscribers-c

Author: Mariya Podchishchaeva (Fznamznon)

Per 6.7.1 p4 > In the declaration of an object with block scope, if the declaration specifiers include thread_local, they shall also include either static or extern.

gcc does complain.

Online demo https://godbolt.org/z/YorncrhKW

cc @AaronBallman

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 24, 2023

@llvm/issue-subscribers-clang-frontend

Author: Mariya Podchishchaeva (Fznamznon)

Per 6.7.1 p4 > In the declaration of an object with block scope, if the declaration specifiers include thread_local, they shall also include either static or extern.

gcc does complain.

Online demo https://godbolt.org/z/YorncrhKW

cc @AaronBallman

@AaronBallman AaronBallman added c11 accepts-invalid confirmed Verified by a second party and removed c labels Oct 24, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 24, 2023

@llvm/issue-subscribers-c11

Author: Mariya Podchishchaeva (Fznamznon)

Per 6.7.1 p4 > In the declaration of an object with block scope, if the declaration specifiers include thread_local, they shall also include either static or extern.

gcc does complain.

Online demo https://godbolt.org/z/YorncrhKW

cc @AaronBallman

@AaronBallman
Copy link
Collaborator

The root cause of this is that we enabled thread_local as a keyword in C23 mode and it is now mapping to the C++ thread_local semantics rather than the C11 _Thread_local semantics. You can see this in: https://godbolt.org/z/e89MsbG1E

@AaronBallman AaronBallman changed the title Clang doesn't complain about thread_local variable in file scope without extern or static. C23 thread_local is mapping to C++ thread_local, not C11 _Thread_local Oct 24, 2023
@AaronBallman AaronBallman added c23 and removed c11 labels Oct 24, 2023
AaronBallman added a commit to AaronBallman/llvm-project that referenced this issue Oct 24, 2023
When implementing thread_local as a keyword in C23, we accidentally
started using C++11 thread_local semantics when using that keyword
instead of using C11 _Thread_local semantics.

This oversight is fixed by pretending the user wrote _Thread_local
instead. This doesn't have the best behavior in terms of diagnostics,
but it does correct the semantic behavior.

Fixes llvm#70068
AaronBallman added a commit that referenced this issue Oct 25, 2023
When implementing thread_local as a keyword in C23, we accidentally
started using C++11 thread_local semantics when using that keyword
instead of using C11 _Thread_local semantics.

This oversight is fixed by pretending the user wrote _Thread_local
instead. This doesn't have the best behavior in terms of diagnostics,
but it does correct the semantic behavior.

Fixes #70068
Fixes #69167
AaronBallman added a commit to AaronBallman/llvm-project that referenced this issue Oct 25, 2023
When implementing thread_local as a keyword in C23, we accidentally
started using C++11 thread_local semantics when using that keyword
instead of using C11 _Thread_local semantics.

This oversight is fixed by pretending the user wrote _Thread_local
instead. This doesn't have the best behavior in terms of diagnostics,
but it does correct the semantic behavior.

Fixes llvm#70068
Fixes llvm#69167
tru pushed a commit to llvm/llvm-project-release-prs that referenced this issue Oct 27, 2023
When implementing thread_local as a keyword in C23, we accidentally
started using C++11 thread_local semantics when using that keyword
instead of using C11 _Thread_local semantics.

This oversight is fixed by pretending the user wrote _Thread_local
instead. This doesn't have the best behavior in terms of diagnostics,
but it does correct the semantic behavior.

Fixes llvm/llvm-project#70068
Fixes llvm/llvm-project#69167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepts-invalid c23 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants