public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/95282] New: atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output
@ 2020-05-23  4:33 rs2740 at gmail dot com
  2020-05-23  6:11 ` [Bug libstdc++/95282] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rs2740 at gmail dot com @ 2020-05-23  4:33 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/95282] atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output
  2020-05-23  4:33 [Bug libstdc++/95282] New: atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output rs2740 at gmail dot com
@ 2020-05-23  6:11 ` redi at gcc dot gnu.org
  2020-05-27 22:10 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2020-05-23  6:11 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-05-23

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/95282] atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output
  2020-05-23  4:33 [Bug libstdc++/95282] New: atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output rs2740 at gmail dot com
  2020-05-23  6:11 ` [Bug libstdc++/95282] " redi at gcc dot gnu.org
@ 2020-05-27 22:10 ` redi at gcc dot gnu.org
  2020-05-27 22:10 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2020-05-27 22:10 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
   Target Milestone|---                         |10.2
              Build|                            |2020-05-23 0:00

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Thanks, I filed PR 95378 for the dubious compiler bug.

Fixed on master so far.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/95282] atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output
  2020-05-23  4:33 [Bug libstdc++/95282] New: atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output rs2740 at gmail dot com
  2020-05-23  6:11 ` [Bug libstdc++/95282] " redi at gcc dot gnu.org
  2020-05-27 22:10 ` redi at gcc dot gnu.org
@ 2020-05-27 22:10 ` cvs-commit at gcc dot gnu.org
  2020-06-16 21:35 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-27 22:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:bbaec68c86f8e89a3460cc022c75d4c4179bfb0a

commit r11-674-gbbaec68c86f8e89a3460cc022c75d4c4179bfb0a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed May 27 22:55:21 2020 +0100

    libstdc++: Fix atomic<FP>::load (PR 95282)

            PR libstdc++/95282
            * include/bits/atomic_base.h (__atomic_impl::load): Add
            cv-qualifiers to parameter so that _Tp is deduced as the
            unqualified type.
            * testsuite/29_atomics/atomic_float/95282.cc: New test.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/95282] atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output
  2020-05-23  4:33 [Bug libstdc++/95282] New: atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output rs2740 at gmail dot com
                   ` (2 preceding siblings ...)
  2020-05-27 22:10 ` cvs-commit at gcc dot gnu.org
@ 2020-06-16 21:35 ` cvs-commit at gcc dot gnu.org
  2020-07-01 22:48 ` cvs-commit at gcc dot gnu.org
  2020-07-01 22:49 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-16 21:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:e40b11a91cb345db1324c3cb8f75b01e28056693

commit r11-1401-ge40b11a91cb345db1324c3cb8f75b01e28056693
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jun 16 22:34:55 2020 +0100

    libstdc++: Strip cv-qualifiers in std::atomic<FP> (PR 95282)

    This improves the previous fix for PR 95282, and extends it to also
    apply to the exchange function (which has a similar problem and would
    become ill-formed with my proposed fix for PR 95378).

            PR libstdc++/95282
            * include/bits/atomic_base.h (__atomic_impl::load): Use the _Val
            alias instead of deducing _Tp as an unqualified type.
            (__atomic_impl::exchange): Use the _Val alias to remove volatile
            from the reinterpret_cast result type.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/95282] atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output
  2020-05-23  4:33 [Bug libstdc++/95282] New: atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output rs2740 at gmail dot com
                   ` (3 preceding siblings ...)
  2020-06-16 21:35 ` cvs-commit at gcc dot gnu.org
@ 2020-07-01 22:48 ` cvs-commit at gcc dot gnu.org
  2020-07-01 22:49 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-01 22:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:161fb9dfc886afb70dcfb45a51571df5e3fce9eb

commit r10-8410-g161fb9dfc886afb70dcfb45a51571df5e3fce9eb
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed May 27 22:55:21 2020 +0100

    libstdc++: Strip cv-qualifiers in std::atomic<FP> (PR 95282)

    This squashes two commits, r11-674 and r11-1401.

            PR libstdc++/95282
            * include/bits/atomic_base.h (__atomic_impl::load): Add
            const-qualifier to parameter so that _Tp is deduced as the
            non-const type, and use _Val to get the unqualified type.
            (__atomic_impl::exchange): Use the _Val alias to remove
            volatile from the reinterpret_cast result type.
            * testsuite/29_atomics/atomic_float/95282.cc: New test.

    (cherry picked from commit e40b11a91cb345db1324c3cb8f75b01e28056693)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/95282] atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output
  2020-05-23  4:33 [Bug libstdc++/95282] New: atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output rs2740 at gmail dot com
                   ` (4 preceding siblings ...)
  2020-07-01 22:48 ` cvs-commit at gcc dot gnu.org
@ 2020-07-01 22:49 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-01 22:49 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 10.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-01 22:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-23  4:33 [Bug libstdc++/95282] New: atomic<floating-point>::load in C++20 calls __atomic_load with a pointer-to-const as the output rs2740 at gmail dot com
2020-05-23  6:11 ` [Bug libstdc++/95282] " redi at gcc dot gnu.org
2020-05-27 22:10 ` redi at gcc dot gnu.org
2020-05-27 22:10 ` cvs-commit at gcc dot gnu.org
2020-06-16 21:35 ` cvs-commit at gcc dot gnu.org
2020-07-01 22:48 ` cvs-commit at gcc dot gnu.org
2020-07-01 22:49 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).