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

    <tr>
        <th>Summary</th>
        <td>
            [libc++] atomic_ref implementation does not support const qualified types or volatile types.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

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

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

<pre>
    Godbolt links for the compile errors for const and volatile qualified ints.
libc++ https://godbolt.org/z/nv854jbzf

Same cases but compilation succeeds.
libstdc++ equivalent https://godbolt.org/z/4YoGWaK4h

Looking at atomic ref implementation, seems like the root cause is when declaring the buffer for the atomic builtin to write the value to(e.g. load), the buffer's type is same as the type that instantiated the atomic_ref tempalte.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEkjFznDAQhX-NaHbMgAADBYUdDy6SzkUmVUag5ZBPSFi7Oo_96zNwl9wlTRqY2WXf2318isgcHGInqkdRPSUq8uxD92KcSwavP7pnrwdvGaxxR4LJB-AZYfTLaiwChuDDuTx6RwzKaTh5q3jrvkVlzWRQg3FMqcieRPZgzTAK-SjkI8zMK4niQcheyP5wdkp9OAjZfwrZu1NTla_D53SePD9f1IIwKkKCIfJlE8XGO6A4joj6xolY_zbDt2hOyqLj__qWP_zzd_W1nG99v3l_NO4AikGxX8wIAScwy2pxQcf7BkJ-AUJcCKw54p5U8J5hVJEQDMH7jA40jlaFTWv7YIjThOFPshftIRrLxgF7eA-Gz1onZSMCeyEbTA8pWK-0kO3melUSsibgj3X3oy0sRXt7r_GsGIwjVo6NYtQ3pj-3gxiXVVnGNNFdoduiVQl2eS2zJq-qokrmrs4yrXK8bwepW1lOsi6LdsIiH8pmmKoxMZ3MZJnVuZRZ3lRVOk11k9U41UWW55kcRZnhooxNrT0tW-6JIYrYtc190yZWDWhpB1LKKy1Cyg3Q0G1Dd0M8kCgza4jpKsOG7Y7yzVj1dHve3_8LtEcC5xkorqsPfKH4Cu4WGoEPV6j3SprEYLt_ODI8xyEd_SJkv610ed2twb_iyEL2-5kkZH--9NTJXwEAAP__lr0rGA">