<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/149686>149686</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            std::atomic_ref broken with const
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jodyhagins
      </td>
    </tr>
</table>

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

The following code should compile.

```c++
#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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsU81uqzoQfhqzGRUZk5CwYJG2N09w99XYHsCtsXNsQ9q3PzIQtTqqZMmKZ77J98NgjGZwRB07PrPja4FzGn3o3r3-GnEwLhbS668uJs3qC6svmPxk1FugfvttPWomzky0EEc_Ww13Hz7gbtIICMq7mGBBO1PJ-IXxy_8jQe-t9XfjBlBe0wOn_HQz9tHHGr4dxcRzPvzCRG2csrMmYPXLRoTV_zF-MS7BhMZtRHLrKQMAAHJpY_EJrH6FirP6UQuU5uDgN23i_MlEW36r21Ds9PqT20OSiWAiOJ8AIY6Y1e1_amKciYkXkHMCdGCmm6WJXMJkvAM5D7l4HykQpJGAPlElSF83At-vL6t5efwcSUPANFKANKKDQJNfsou5TS3wZ0ZrekMhgqTeBwKF1uYG1vC3t13dKqnhJcDKOxJNEQJh9A6lJeiDn9aJ8UbK9EatTDPL_Niv9EZM8CN4E3e1vQ__upmB6PQKRukX2jLfw45gerhT1gbWyJj0Hvf2ASmLbjVoUOsgs10-wBQXVRa6q3Vbt1hQV52Oom2aU9sUY9ecuThXR1HLnldSI6LQqtFn2VT8dDycC9MJLo78VLWiruqqKcUJScpD00rV9m1F7MBpQmNLa5ep9GEo1iS76tA256awKMnGdWeEcHR_5CzyCoUug57kPER24NbEFL_HJJMs_bZOIIP_ILcLz3YWc7DdmNIt5l5xZeI6mDTOslR-YuKaZ-7X0y34d1KJievKJDJx3akunfgbAAD__9I2QMc">