Skip to content

[libc++] Accepts invalid struct _Atomic(T) because _Atomic expands to a class template #168579

@eisenwave

Description

@eisenwave

https://godbolt.org/z/97x9Ms8eK

#include <stdatomic.h>
struct _Atomic(int) x;

This code should raise an error (or warning), but is falsely accepted by Clang.

https://eel.is/c++draft/stdatomic.h.syn specifies _Atomic as expanding to an exposition-only std-atomic alias template. This forbids the use of a struct keyword.

The bug occurs because libc++ defines _Atomic like:

#define _Atomic(_Tp) ::std::atomic<_Tp>

# ifdef _Atomic
# undef _Atomic
# endif
# define _Atomic(_Tp) ::std::atomic<_Tp>

See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122738

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepts-invalidlibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions