public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/55979] New: [C++11] std::list range construction imposes unnecessary conversion constraints
@ 2013-01-14 21:12 daniel.kruegler at googlemail dot com
  2013-01-14 22:14 ` [Bug libstdc++/55979] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-01-14 21:12 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55979

             Bug #: 55979
           Summary: [C++11] std::list 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 provided by Jonathan compiled with gcc 4.8.0 20130113
(experimental) using the flags

-Wall -std=c++11 -pedantic

is rejected:

//-------------------------------
#include <list>

struct A
{
  A(int) { }
  A(const A&) = delete;
  A& operator=(const A&) = delete;
};

int main()
{
  int i[] = {1, 2};
  std::list<A> li(i, i + 2);
}
//-------------------------------

"[..]gcc\include\c++\4.8.0\bits\stl_list.h||In instantiation of
'std::_List_node<_Tp>::_List_node(_Args&& ...) [with _Args = {A}; _Tp = A]':|
[..]\gcc\include\c++\4.8.0\ext\new_allocator.h|120|required from 'void
__gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up =
std::_List_node<A>; _Args = {A}; _Tp = std::_List_node<A>]'|
[..]gcc\include\c++\4.8.0\bits\stl_list.h|506|required from 'std::list<_Tp,
_Alloc>::_Node* std::list<_Tp, _Alloc>::_M_create_node(_Args&& ...) [with _Args
= {A}; _Tp = A; _Alloc = std::allocator<A>; std::list<_Tp, _Alloc>::_Node =
std::_List_node<A>]'|
[..]gcc\include\c++\4.8.0\bits\stl_list.h|1558|required from 'void
std::list<_Tp, _Alloc>::_M_insert(std::list<_Tp, _Alloc>::iterator, _Args&&
...) [with _Args = {A}; _Tp = A; _Alloc = std::allocator<A>; std::list<_Tp,
_Alloc>::iterator = std::_List_iterator<A>]'|
[..]gcc\include\c++\4.8.0\bits\stl_list.h|1022|required from 'void
std::list<_Tp, _Alloc>::push_back(std::list<_Tp, _Alloc>::value_type&&) [with
_Tp = A; _Alloc = std::allocator<A>; std::list<_Tp, _Alloc>::value_type = A]'|
[..]gcc\include\c++\4.8.0\bits\stl_list.h|1491|required from 'void
std::list<_Tp, _Alloc>::_M_initialize_dispatch(_InputIterator, _InputIterator,
std::__false_type) [with _InputIterator = int*; _Tp = A; _Alloc =
std::allocator<A>]'|
[..]gcc\include\c++\4.8.0\bits\stl_list.h|628|required from 'std::list<_Tp,
_Alloc>::list(_InputIterator, _InputIterator, const allocator_type&) [with
_InputIterator = int*; <template-parameter-2-2> = void; _Tp = A; _Alloc =
std::allocator<A>; std::list<_Tp, _Alloc>::allocator_type =
std::allocator<A>]'|
main.cpp|13|required from here|
[..]gcc\include\c++\4.8.0\bits\stl_list.h|115|error: use of deleted function
'A::A(const A&)'|
main.cpp|6|error: declared here
"

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.

This issue is similar to bug 55977 involving std::vector, but occurs even with
the default allocator and for all iterator categories except input iterator,
therefore this issue is reported separately.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/55979] [C++11] std::list range construction imposes unnecessary conversion constraints
  2013-01-14 21:12 [Bug libstdc++/55979] New: [C++11] std::list range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
@ 2013-01-14 22:14 ` redi at gcc dot gnu.org
  2013-03-17 11:21 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-14 22:14 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55979

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] 5+ messages in thread

* [Bug libstdc++/55979] [C++11] std::list range construction imposes unnecessary conversion constraints
  2013-01-14 21:12 [Bug libstdc++/55979] New: [C++11] std::list range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
  2013-01-14 22:14 ` [Bug libstdc++/55979] " redi at gcc dot gnu.org
@ 2013-03-17 11:21 ` paolo.carlini at oracle dot com
  2013-03-17 18:28 ` paolo at gcc dot gnu.org
  2013-03-27 11:40 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-17 11:21 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55979

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 #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-17 11:21:11 UTC ---
Seems easy and fixable in 4.8.1 too.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/55979] [C++11] std::list range construction imposes unnecessary conversion constraints
  2013-01-14 21:12 [Bug libstdc++/55979] New: [C++11] std::list range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
  2013-01-14 22:14 ` [Bug libstdc++/55979] " redi at gcc dot gnu.org
  2013-03-17 11:21 ` paolo.carlini at oracle dot com
@ 2013-03-17 18:28 ` paolo at gcc dot gnu.org
  2013-03-27 11:40 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo at gcc dot gnu.org @ 2013-03-17 18:28 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55979

--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2013-03-17 18:28:01 UTC ---
Author: paolo
Date: Sun Mar 17 18:27:52 2013
New Revision: 196755

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196755
Log:
2013-03-17  Paolo Carlini  <paolo.carlini@oracle.com>

    PR libstdc++/55979
    * include/bits/stl_list.h (_M_initialize_dispatch(_InputIterator,
    _InputIterator, __false_type)): Use emplace_back.
    * testsuite/23_containers/list/cons/55979.cc: New.
    * testsuite/23_containers/list/modifiers/1.h: Adjust.
    * testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
    Adjust dg-error line number.

Added:
    trunk/libstdc++-v3/testsuite/23_containers/list/cons/55979.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/stl_list.h
    trunk/libstdc++-v3/testsuite/23_containers/list/modifiers/1.h
   
trunk/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libstdc++/55979] [C++11] std::list range construction imposes unnecessary conversion constraints
  2013-01-14 21:12 [Bug libstdc++/55979] New: [C++11] std::list range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2013-03-17 18:28 ` paolo at gcc dot gnu.org
@ 2013-03-27 11:40 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-27 11:40 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55979

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-27 11:40:30 UTC ---
Fixed 4.8.1 too.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-03-27 11:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-14 21:12 [Bug libstdc++/55979] New: [C++11] std::list range construction imposes unnecessary conversion constraints daniel.kruegler at googlemail dot com
2013-01-14 22:14 ` [Bug libstdc++/55979] " redi at gcc dot gnu.org
2013-03-17 11:21 ` paolo.carlini at oracle dot com
2013-03-17 18:28 ` paolo at gcc dot gnu.org
2013-03-27 11:40 ` paolo.carlini at oracle 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).