public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/94164] New: [Regression 10] std::unintialized_fill_n fails to compile
@ 2020-03-13 8:42 laurent.stacul at gmail dot com
2020-03-13 9:15 ` [Bug libstdc++/94164] [10 Regression] " rguenth at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: laurent.stacul at gmail dot com @ 2020-03-13 8:42 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/94164] [10 Regression] std::unintialized_fill_n fails to compile
2020-03-13 8:42 [Bug libstdc++/94164] New: [Regression 10] std::unintialized_fill_n fails to compile laurent.stacul at gmail dot com
@ 2020-03-13 9:15 ` rguenth at gcc dot gnu.org
2020-03-13 10:26 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-03-13 9:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94164
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.0
Summary|[Regression 10] |[10 Regression]
|std::unintialized_fill_n |std::unintialized_fill_n
|fails to compile |fails to compile
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/94164] [10 Regression] std::unintialized_fill_n fails to compile
2020-03-13 8:42 [Bug libstdc++/94164] New: [Regression 10] std::unintialized_fill_n fails to compile laurent.stacul at gmail dot com
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
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-03-13 10:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94164
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
That's not an iterator.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/94164] [10 Regression] std::unintialized_fill_n fails to compile
2020-03-13 8:42 [Bug libstdc++/94164] New: [Regression 10] std::unintialized_fill_n fails to compile laurent.stacul at gmail dot com
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
3 siblings, 0 replies; 5+ messages in thread
From: laurent.stacul at gmail dot com @ 2020-03-13 10:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94164
--- Comment #2 from Laurent Stacul <laurent.stacul at gmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> That's not an iterator.
Yes sure. I reduced my example to have the minimal example. I will add all de
needed requirement of an iterator if needed.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/94164] [10 Regression] std::unintialized_fill_n fails to compile
2020-03-13 8:42 [Bug libstdc++/94164] New: [Regression 10] std::unintialized_fill_n fails to compile laurent.stacul at gmail dot com
` (2 preceding siblings ...)
2020-03-13 10:32 ` laurent.stacul at gmail dot com
@ 2020-03-16 15:05 ` laurent.stacul at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: laurent.stacul at gmail dot com @ 2020-03-16 15:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94164
Laurent Stacul <laurent.stacul at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Laurent Stacul <laurent.stacul at gmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> That's not an iterator.
Okay. Thanks for the information. When all the requirements are written it
works.
Let's close this one.
Regards,
Stac
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-16 15:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13 8:42 [Bug libstdc++/94164] New: [Regression 10] std::unintialized_fill_n fails to compile laurent.stacul at gmail dot com
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
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).