This is an archive of the discontinued LLVM Phabricator instance.

[C2x] Remove the ATOMIC_VAR_INIT macro from stdatomic.h
ClosedPublic

Authored by aaron.ballman on Feb 16 2023, 8:29 AM.

Details

Reviewers
jyknight
cor3ntin
Group Reviewers
Restricted Project
Restricted Project
Commits
rG898c673e0835: [C2x] Remove the ATOMIC_VAR_INIT macro from stdatomic.h
Summary

This implements WG14 N2886 (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2886.htm) which removed the macro entirely. (NB the macro was deprecated in C17.) As the paper is not particularly clear on what alternative was picked, here are my notes from the May 2022 meeting:

Does WG14 wish to adopt variant 1, change 3.2, 3.3, and 3.4 from N2886 into C23? 14/2/2 (consensus).
Does WG14 want to exchange Variant 1 with Variant 2 in N2886 in C23? 9/3/6 (consensus).
(There was no sentiment in the room for either Variant 3 or Variant 4 so those were not voted on.)
Does WG14 want to integrate change 3.5 in N2886 into C23? 8/1/9 (consensus).
Does WG14 want to integrate change 3.6 in N2886 into C23? 2/5/9 (no consensus).

I've added the libc++ reviewers to ensure this doesn't negatively impact <atomic> and the clang-vendors group for early awareness about a potentially breaking change. Any code that is broken by the removal can remove the use of ATOMIC_VAR_INIT and use regular initialization instead.

Diff Detail

Event Timeline

aaron.ballman created this revision.Feb 16 2023, 8:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 16 2023, 8:29 AM
aaron.ballman requested review of this revision.Feb 16 2023, 8:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 16 2023, 8:29 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
cor3ntin added inline comments.
clang/docs/ReleaseNotes.rst
97

Just confirming we want to pluralize standards here? It kind of look weird to my non native eyes.

clang/lib/Headers/stdatomic.h
50

C++ uses the date of the meeting where the change was accepted, I assume C is different?

61

Should we add a message informing people it's remove in C23?

aaron.ballman added inline comments.Feb 21 2023, 5:43 AM
clang/docs/ReleaseNotes.rst
97

I'll reword it to be less awkward because I can't convince myself one way or the other. :-D

clang/lib/Headers/stdatomic.h
50

__STDC_VERSION__ is akin to __cplusplus, so it's the date of publication (which we don't have yet, which is why I'm using a placeholder).

61

Eh, that gets annoying because it's removed in C23 but still present in C++23. I think the current wording is likely fine.

cor3ntin accepted this revision.Feb 24 2023, 9:05 AM

Sorry it took me a while to reply to you. I think you convinced me this is fine as-is! Thanks

clang/lib/Headers/stdatomic.h
50

202000L is extra arbitrary, but.. there is a fixme so i guess it's fine!

61

Fair enough. It's likely C++ will want to remove it too when rebased on C23 though

This revision is now accepted and ready to land.Feb 24 2023, 9:05 AM

Thanks for the heads up. As noted in another comment, I don't think this impacts libc++ because C++23 (unfortunately) still provides the macro AFAICT. We define it ourselves in libcxx/include/__atomic/atomic_init.h.