From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 39EC73940CF5; Fri, 13 Mar 2020 08:42:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39EC73940CF5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584088923; bh=3jUlnpdl5ghPPpJzmRzA1YrRqRa4rqkUJLEdQ0XkYSA=; h=From:To:Subject:Date:From; b=bVif/+g0gGtD8XOP08wczQKka7fpQPPK86HEQl7mpF+tv+U8IM5a+dcLe6nnwgn9k gkFVMGHgtSjQ/tsr3RlTDIGwSoEC1mi+Pz+qdVeHIDOlQr2TWN1fKwMNDaxdUmqK4g Z6f2fCC4J6jgeDU08zh62R+/kBa93Bck6yPYd0gA= From: "laurent.stacul at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/94164] New: [Regression 10] std::unintialized_fill_n fails to compile Date: Fri, 13 Mar 2020 08:42:02 +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: laurent.stacul at gmail dot com 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, 13 Mar 2020 08:42:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94164 Bug ID: 94164 Summary: [Regression 10] std::unintialized_fill_n fails to compile Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: laurent.stacul at gmail dot com Target Milestone: --- Hello, I have this piece of code: #include template struct ref { typedef T value_type; typedef T* pointer; typedef T& reference; typedef ptrdiff_t difference_type; typedef std::random_access_iterator_tag iterator_category; int d; explicit ref(int =3D0): d(-1) {} operator pointer() { if (d =3D=3D -1) { return 0; } else { return reinterpret_cast(this + d); } } ref& operator++() { d +=3D sizeof(value_type); return *this; } }; int main(int, const char *[]) { ref r; std::uninitialized_fill_n(r, 10, 'a'); return 0; } I compile it with the following command (the -std option is not important): $ g++ -Wall -Wextra -std=3Dgnu++2a -c -o main.o main.cpp When I compile it with gcc (GCC) 10.0.1 20200305, if fails with the followi= ng error: /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h: In instantiation of 'constexpr _OutputIterator std::__fill_n_a(_OutputIterator, _Size, const _T= p&, std::random_access_iterator_tag) [with _OutputIterator =3D ref; _Size= =3D int; _Tp =3D char]': /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:1085:29: required from 'constexpr _OI std::fill_n(_OI, _Size, const _Tp&) [with _OI =3D ref; _Size =3D int; _Tp =3D char]' /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_uninitialized.h:254:29: requ= ired from 'static _ForwardIterator std::__uninitialized_fill_n::__uninit_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator =3D ref; _Size =3D int; _Tp =3D c har]' /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_uninitialized.h:289:17: requ= ired from '_ForwardIterator std::uninitialized_fill_n(_ForwardIterator, _Size, c= onst _Tp&) [with _ForwardIterator =3D ref; _Size =3D int; _Tp =3D char]' main.cpp:32:41: required from here /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:1056:20: error: no matching function for call to '__fill_a(ref&, ref::pointer, con= st char&)' 1056 | std::__fill_a(__first, __first + __n, __value); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:904:5: note: candid= ate: 'template constexpr void std::__fill_a(_FIte, _FIte, const _Tp&)' 904 | __fill_a(_FIte __first, _FIte __last, const _Tp& __value) | ^~~~~~~~ /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:904:5: note: temp= late argument deduction/substitution failed: /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:1056:20: note:=20=20 deduced conflicting types for parameter '_FIte' ('ref' and 'char*') 1056 | std::__fill_a(__first, __first + __n, __value); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:909:5: note: candid= ate: 'template void std::__fill_a(const __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, const __gnu_debug::_Safe_iterator<_Ite, _Seq , _Cat>&, const _Tp&)' 909 | __fill_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, | ^~~~~~~~ /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:909:5: note: temp= late argument deduction/substitution failed: /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:1056:20: note:=20=20 'ref' is not derived from 'const __gnu_debug::_Safe_iterator<_Ite, _S= eq, _Cat>' 1056 | std::__fill_a(__first, __first + __n, __value); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:1057:22: error: cou= ld not convert '(__first.ref::operator ref::pointer() + ((sizetype)__n))' from 'ref::pointer' {aka 'char*'} to 'ref' 1057 | return __first + __n; | ~~~~~~~~^~~~~ | | | ref::pointer {aka char*} make: *** [Makefile:6: main.o] Error 1 Conversely, this code compiles with gcc (GCC) 9.2.1.=20 Maybe is it related to https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommit;h=3D6004c17b4d1a2dd1e1936b2= e705a5ccfb6e48ab2 but I don' t know if the current bahviour is expected. Stac=