https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95282

            Bug ID: 95282
           Summary: atomic<floating-point>::load in C++20 calls
                    __atomic_load with a pointer-to-const as the output
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

We have

      _Fp
      load(memory_order __m = memory_order_seq_cst) const noexcept
      { return __atomic_impl::load(&_M_fp, __m); }

which calls

    template<typename _Tp>
      _GLIBCXX_ALWAYS_INLINE _Tp
      load(_Tp* __ptr, memory_order __m) noexcept
      {
        alignas(_Tp) unsigned char __buf[sizeof(_Tp)];
        _Tp* __dest = reinterpret_cast<_Tp*>(__buf);
        __atomic_load(__ptr, __dest, int(__m));
        return *__dest;
      }

Here &_M_fp is a const _Fp*, so _Tp is const-qualified. GCC's __atomic_load
appears to happily tolerate a pointer-to-const dest (which seems rather
dubious), but Clang's doesn't.

Reply via email to