public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "laurent.stacul at gmail dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-94164-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94164 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 <memory> template<typename T> 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 =0): d(-1) {} operator pointer() { if (d == -1) { return 0; } else { return reinterpret_cast<pointer>(this + d); } } ref& operator++() { d += sizeof(value_type); return *this; } }; int main(int, const char *[]) { ref<char> 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=gnu++2a -c -o main.o main.cpp When I compile it with gcc (GCC) 10.0.1 20200305, if fails with the following 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 _Tp&, std::random_access_iterator_tag) [with _OutputIterator = ref<char>; _Size = int; _Tp = 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 = ref<char>; _Size = int; _Tp = char]' /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_uninitialized.h:254:29: required from 'static _ForwardIterator std::__uninitialized_fill_n<true>::__uninit_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator = ref<char>; _Size = int; _Tp = c har]' /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_uninitialized.h:289:17: required from '_ForwardIterator std::uninitialized_fill_n(_ForwardIterator, _Size, const _Tp&) [with _ForwardIterator = ref<char>; _Size = int; _Tp = 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<char>&, ref<char>::pointer, const 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: candidate: 'template<class _FIte, class _Tp> 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: template argument deduction/substitution failed: /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:1056:20: note: deduced conflicting types for parameter '_FIte' ('ref<char>' 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: candidate: 'template<class _Ite, class _Seq, class _Cat, class _Tp> 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: template argument deduction/substitution failed: /x86_64-v20.0.13/include/c++/10.0.1/bits/stl_algobase.h:1056:20: note: 'ref<char>' is not derived from 'const __gnu_debug::_Safe_iterator<_Ite, _Seq, _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: could not convert '(__first.ref<char>::operator ref<char>::pointer() + ((sizetype)__n))' from 'ref<char>::pointer' {aka 'char*'} to 'ref<char>' 1057 | return __first + __n; | ~~~~~~~~^~~~~ | | | ref<char>::pointer {aka char*} make: *** [Makefile:6: main.o] Error 1 Conversely, this code compiles with gcc (GCC) 9.2.1. Maybe is it related to https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=6004c17b4d1a2dd1e1936b2e705a5ccfb6e48ab2 but I don' t know if the current bahviour is expected. Stac
next reply other threads:[~2020-03-13 8:42 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-13 8:42 laurent.stacul at gmail dot com [this message] 2020-03-13 9:15 ` [Bug libstdc++/94164] [10 Regression] " rguenth at gcc dot gnu.org 2020-03-13 10:26 ` redi at gcc dot gnu.org 2020-03-13 10:32 ` laurent.stacul at gmail dot com 2020-03-16 15:05 ` laurent.stacul at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-94164-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).