Skip to content

std::atomic_ref broken with const #149686

@jodyhagins

Description

@jodyhagins

std::atomic_ref::load() should work with a const value.

The following code should compile.

#include <atomic>
int main()
{
    int const x = 10;
    return std::atomic_ref(x).load();
}

This is not a shallow const issue, but an implementation bug, where the exact type of the value is used rather than removing the cv qualifiers before calling __atomic_load. This seems reasonable from the specification, the fact that load() is const for std::atomic, and the above code compiles if we use libstdc++ with clang, gcc, icc, or msvc.

Metadata

Metadata

Assignees

Labels

libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions