public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints
@ 2013-01-14 20:51 daniel.kruegler at googlemail dot com
2013-01-14 22:13 ` [Bug libstdc++/55977] " redi at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-01-14 20:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55977
Bug #: 55977
Summary: [C++11] vector range construction imposes unnecessary
conversion constraints
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: daniel.kruegler@googlemail.com
The following code compiled with gcc 4.8.0 20130113 (experimental) using the
flags
-Wall -std=c++11 -pedantic
is rejected:
//-------------------------------------
#include <memory>
#include <utility>
#include <vector>
#include <iterator>
#include <iostream>
template <class T>
struct MyAllocator {
std::allocator<T> base;
typedef T value_type;
MyAllocator() = default;
template <class U>
MyAllocator(const MyAllocator<U>& other) : base(other.base) {}
T* allocate(std::size_t n) { return base.allocate(n); }
void deallocate(T* p, std::size_t n) { return base.deallocate(p, n); }
template <class U, class... Args>
void construct(U* p, Args&&... args)
{
::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
}
};
struct A {
private:
friend class MyAllocator<A>;
A(int value) : value(value) {}
int value;
public:
A() : value() {}
int get() const { return value; }
};
int main()
{
std::vector<A, MyAllocator<A>> v1;
const int i = 1;
v1.emplace_back(i); // OK
std::vector<A, MyAllocator<A>> v2(std::istream_iterator<int>(std::cin), {});
// Error
}
//-------------------------------------
"[..]gcc\include\c++\4.8.0\bits\stl_vector.h||In instantiation of 'void
std::vector<_Tp, _Alloc>::_M_range_initialize(_InputIterator, _InputIterator,
std::input_iterator_tag) [with _InputIterator = std::istream_iterator<int>; _Tp
= A; _Alloc = MyAllocator<A>]':|
[..]gcc\include\c++\4.8.0\bits\stl_vector.h|1178|required from 'void
std::vector<_Tp, _Alloc>::_M_initialize_dispatch(_InputIterator,
_InputIterator, std::__false_type) [with _InputIterator =
std::istream_iterator<int>; _Tp = A; _Alloc = MyAllocator<A>]'|
[..]gcc\include\c++\4.8.0\bits\stl_vector.h|396|required from 'std::vector<_Tp,
_Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with
_InputIterator = std::istream_iterator<int>; <template-parameter-2-2> = void;
_Tp = A; _Alloc = MyAllocator<A>; std::vector<_Tp, _Alloc>::allocator_type =
MyAllocator<A>]'|
main.cpp|38|required from here|
main.cpp|26|error: 'A::A(int)' is private|
[..]gcc\include\c++\4.8.0\bits\stl_vector.h|1188|error: within this context"
The error is due to a call of push_back with an previous int->A conversion.
Such an conversion from the iterator's value_type to the containers value_type
is not feasible. The specification of the corresponding constructor is
(indirectly) ruled by Table 100, expression X(i, j):
"Requires: T shall be EmplaceConstructible into X from *i."
Move/CopyConstructible or Convertible to value_type are not required.
Instead of invoking push_back this constructor should internally invoke the
equivalent of emplace_back.
The same problem also occurs for other standard containers such as std::list.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/55977] [C++11] vector range construction imposes unnecessary conversion constraints
2013-01-14 20:51 [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
@ 2013-01-14 22:13 ` redi at gcc dot gnu.org
2013-01-14 22:18 ` daniel.kruegler at googlemail dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-14 22:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55977
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-01-14
Ever Confirmed|0 |1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/55977] [C++11] vector range construction imposes unnecessary conversion constraints
2013-01-14 20:51 [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
2013-01-14 22:13 ` [Bug libstdc++/55977] " redi at gcc dot gnu.org
@ 2013-01-14 22:18 ` daniel.kruegler at googlemail dot com
2013-03-17 11:22 ` paolo.carlini at oracle dot com
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-01-14 22:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55977
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2013-01-14 22:18:08 UTC ---
I just notice that the implementation of construct should be changed to
template <class U, class... Args>
void construct(U* p, Args&&... args)
{
::new (static_cast<void*>(p)) U(std::forward<Args>(args)...);
}
instead. The slight difference (Replace T by U) doesn't matter in this example,
but for correctness reasons should be applied.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/55977] [C++11] vector range construction imposes unnecessary conversion constraints
2013-01-14 20:51 [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
2013-01-14 22:13 ` [Bug libstdc++/55977] " redi at gcc dot gnu.org
2013-01-14 22:18 ` daniel.kruegler at googlemail dot com
@ 2013-03-17 11:22 ` paolo.carlini at oracle dot com
2013-03-18 10:16 ` paolo at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-17 11:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55977
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot
|gnu.org |com
Target Milestone|--- |4.8.1
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-17 11:22:08 UTC ---
Likewise, thanks Daniel.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/55977] [C++11] vector range construction imposes unnecessary conversion constraints
2013-01-14 20:51 [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
` (2 preceding siblings ...)
2013-03-17 11:22 ` paolo.carlini at oracle dot com
@ 2013-03-18 10:16 ` paolo at gcc dot gnu.org
2013-03-27 14:33 ` paolo.carlini at oracle dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: paolo at gcc dot gnu.org @ 2013-03-18 10:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55977
--- Comment #3 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2013-03-18 10:16:07 UTC ---
Author: paolo
Date: Mon Mar 18 10:15:56 2013
New Revision: 196774
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196774
Log:
2013-03-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/55977 (partial, std::vector and std::deque bits)
* include/bits/stl_vector.h (_M_range_initialize(_InputIterator,
_InputIterator, std::input_iterator_tag)): Use emplace_back.
* include/bits/deque.tcc (_M_range_initialize(_InputIterator,
_InputIterator, std::input_iterator_tag)): Likewise.
* testsuite/23_containers/vector/cons/55977.cc: New.
* testsuite/23_containers/deque/cons/55977.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
Added:
trunk/libstdc++-v3/testsuite/23_containers/deque/cons/55977.cc
trunk/libstdc++-v3/testsuite/23_containers/vector/cons/55977.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/deque.tcc
trunk/libstdc++-v3/include/bits/stl_vector.h
trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/55977] [C++11] vector range construction imposes unnecessary conversion constraints
2013-01-14 20:51 [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
` (3 preceding siblings ...)
2013-03-18 10:16 ` paolo at gcc dot gnu.org
@ 2013-03-27 14:33 ` paolo.carlini at oracle dot com
2013-05-31 11:03 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-27 14:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55977
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |NEW
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-27 14:33:25 UTC ---
std::vector and std::deque fixed for 4.8.1 too.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/55977] [C++11] vector range construction imposes unnecessary conversion constraints
2013-01-14 20:51 [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
` (4 preceding siblings ...)
2013-03-27 14:33 ` paolo.carlini at oracle dot com
@ 2013-05-31 11:03 ` jakub at gcc dot gnu.org
2013-10-16 9:51 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-05-31 11:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55977
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.1 |4.8.2
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.1 has been released.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/55977] [C++11] vector range construction imposes unnecessary conversion constraints
2013-01-14 20:51 [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
` (5 preceding siblings ...)
2013-05-31 11:03 ` jakub at gcc dot gnu.org
@ 2013-10-16 9:51 ` jakub at gcc dot gnu.org
2015-06-22 14:26 ` rguenth at gcc dot gnu.org
2015-06-22 15:25 ` redi at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-10-16 9:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55977
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.2 |4.8.3
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.2 has been released.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/55977] [C++11] vector range construction imposes unnecessary conversion constraints
2013-01-14 20:51 [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
` (6 preceding siblings ...)
2013-10-16 9:51 ` jakub at gcc dot gnu.org
@ 2015-06-22 14:26 ` rguenth at gcc dot gnu.org
2015-06-22 15:25 ` redi at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-22 14:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55977
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.3 |---
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/55977] [C++11] vector range construction imposes unnecessary conversion constraints
2013-01-14 20:51 [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
` (7 preceding siblings ...)
2015-06-22 14:26 ` rguenth at gcc dot gnu.org
@ 2015-06-22 15:25 ` redi at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2015-06-22 15:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55977
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |4.8.1
Known to fail| |4.8.0
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This was fixed for 4.8.1
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-06-22 15:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-14 20:51 [Bug libstdc++/55977] New: [C++11] vector range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
2013-01-14 22:13 ` [Bug libstdc++/55977] " redi at gcc dot gnu.org
2013-01-14 22:18 ` daniel.kruegler at googlemail dot com
2013-03-17 11:22 ` paolo.carlini at oracle dot com
2013-03-18 10:16 ` paolo at gcc dot gnu.org
2013-03-27 14:33 ` paolo.carlini at oracle dot com
2013-05-31 11:03 ` jakub at gcc dot gnu.org
2013-10-16 9:51 ` jakub at gcc dot gnu.org
2015-06-22 14:26 ` rguenth at gcc dot gnu.org
2015-06-22 15:25 ` 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).