From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0612B39450E7; Fri, 27 Mar 2020 09:06:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0612B39450E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1585299978; bh=3/TABb04U+HvqG8Q12Zzcv6bGHInPlld4F94cX3JRf4=; h=From:To:Subject:Date:From; b=pk51vFGHOjDuiSqnKnKjpKJWZSbxB8pmZxjjamGP34dO4peU9qdokgiipQUQgYSh8 EVh8rVPmT8QZTQxcMEHze4LOwXkxsAYM7OZXMvwblf0HAUEbLZAmmP7z/7dEpCVZS3 l7h0IVTv8/OM2eizbUN4TToxRiIzRYjPd5mozJ8Q= From: "alex at grundis dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/94353] New: std::copy* breaks when one type is volatile Date: Fri, 27 Mar 2020 09:06:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alex at grundis dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2020 09:06:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94353 Bug ID: 94353 Summary: std::copy* breaks when one type is volatile Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: alex at grundis dot de Target Milestone: --- The following code breaks: #include void foo(const char* b, volatile char* d){ std::copy_n(b, 10, d); } This is a regression from earlier versions where it worked fine. The reason= is that at some point `struct __copy_move<_IsMove, true, random_access_iterator_tag>::__copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result)` is called where it fails to deduce `__Tp` because it is `ch= ar` and `volatile char` Full stack:=20 In file included from /usr/local/include/c++/10.0.1/bits/char_traits.h:39, from /usr/local/include/c++/10.0.1/string:40, from /usr/local/include/c++/10.0.1/stdexcept:39, from /usr/local/include/c++/10.0.1/system_error:41, from /home/jakecooke/Code/CPP/Glade/src/simulator/abseil-cpp/absl/strings/charco= nv.h:18, from /home/jakecooke/Code/CPP/Glade/src/simulator/abseil-cpp/absl/strings/charco= nv.cc:15: /usr/local/include/c++/10.0.1/bits/stl_algobase.h: In instantiation of 'constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove =3D fa= lse; _II =3D const char*; _OI =3D volatile char*]': /usr/local/include/c++/10.0.1/bits/stl_algobase.h:533:42: required from 'constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove =3D fa= lse; _II =3D const char*; _OI =3D volatile char*]' /usr/local/include/c++/10.0.1/bits/stl_algobase.h:541:31: required from 'constexpr _OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove =3D fal= se; _II =3D const char*; _OI =3D volatile char*]' /usr/local/include/c++/10.0.1/bits/stl_algobase.h:596:7: required from 'constexpr _OI std::copy(_II, _II, _OI) [with _II =3D const char*; _OI =3D = volatile char*]' /usr/local/include/c++/10.0.1/bits/stl_algo.h:820:23: required from 'constexpr _OutputIterator std::__copy_n(_RandomAccessIterator, _Size, _OutputIterator, std::random_access_iterator_tag) [with _RandomAccessIterat= or =3D const char*; _Size =3D long int; _OutputIterator =3D volatile char*]' /usr/local/include/c++/10.0.1/bits/stl_algo.h:847:27: required from 'constexpr _OIter std::copy_n(_IIter, _Size, _OIter) [with _IIter =3D const char*; _Size =3D long int; _OIter =3D volatile char*]' /home/jakecooke/Code/CPP/Glade/src/simulator/abseil-cpp/absl/strings/charco= nv.cc:301:7: required from 'bool absl::{anonymous}::HandleEdgeCase(const absl::strings_internal::ParsedFloat&, bool, FloatType*) [with FloatType =3D double]' /home/jakecooke/Code/CPP/Glade/src/simulator/abseil-cpp/absl/strings/charco= nv.cc:636:23: required from 'absl::from_chars_result absl::{anonymous}::FromCharsImpl(c= onst char*, const char*, FloatType&, absl::chars_format) [with FloatType =3D dou= ble]' /home/jakecooke/Code/CPP/Glade/src/simulator/abseil-cpp/absl/strings/charco= nv.cc:681:47: required from here /usr/local/include/c++/10.0.1/bits/stl_algobase.h:499:30: error: no matching function for call to 'std::__copy_move::__copy_m(const char*&, const char*&, vola= tile char*&)' 498 | return std::__copy_move<_IsMove, __simple, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 499 | _Category>::__copy_m(__first, __last, __result); | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/c++/10.0.1/bits/stl_algobase.h:441:2: note: candidate: 'template static constexpr _Tp* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(const _Tp*, const _Tp*, _Tp*) [w= ith _Tp =3D _Tp; bool _IsMove =3D false]' 441 | __copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result) | ^~~~~~~~ /usr/local/include/c++/10.0.1/bits/stl_algobase.h:441:2: note: template argument deduction/substitution failed: /usr/local/include/c++/10.0.1/bits/stl_algobase.h:499:30: note: deduced conflicting types for parameter '_Tp' ('char' and 'volatile char') 498 | return std::__copy_move<_IsMove, __simple, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 499 | _Category>::__copy_m(__first, __last, __result); | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ It seems that this should be fixed by https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommit;h=3D462f6c2041fad058abcdd51= 22e99a024f69a39d5 because `__memcpyable` should return false. But there doesn't seem to be a test case for mixed volatile pointers. I'd sugge= st to add them=