https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63274

            Bug ID: 63274
           Summary: std::list uses T(...) instead of T{...} in
                    implementation of emplace()
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: d.v.a at ngs dot ru

Example:

#include<list>

struct C { int a, b; };

int main()
{
    std::list<C> l;
    l.emplace_back(1, 2);
}


$ g++ -std=c++11 -Wall example.cpp

In file included from /opt/gcc-4.9.0/include/c++/4.9.0/list:63:0,

from /tmp/gcc-explorer-compiler114816-7339-16y749p/example.cpp:1:

/opt/gcc-4.9.0/include/c++/4.9.0/bits/stl_list.h: In instantiation of
‘std::_List_node<_Tp>::_List_node(_Args&& ...) [with _Args = {int, int}; _Tp =
C]’:

/opt/gcc-4.9.0/include/c++/4.9.0/ext/new_allocator.h:120:4: required from ‘void
__gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up =
std::_List_node<C>; _Args = {int, int}; _Tp = std::_List_node<C>]’

/opt/gcc-4.9.0/include/c++/4.9.0/bits/stl_list.h:514:8: required from
‘std::list<_Tp, _Alloc>::_Node* std::list<_Tp, _Alloc>::_M_create_node(_Args&&
...) [with _Args = {int, int}; _Tp = C; _Alloc = std::allocator<C>;
std::list<_Tp, _Alloc>::_Node = std::_List_node<C>]’

/opt/gcc-4.9.0/include/c++/4.9.0/bits/stl_list.h:1688:63: required from ‘void
std::list<_Tp, _Alloc>::_M_insert(std::list<_Tp, _Alloc>::iterator, _Args&&
...) [with _Args = {int, int}; _Tp = C; _Alloc = std::allocator<C>;
std::list<_Tp, _Alloc>::iterator = std::_List_iterator<C>]’

/opt/gcc-4.9.0/include/c++/4.9.0/bits/stl_list.h:1039:11: required from ‘void
std::list<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, int}; _Tp
= C; _Alloc = std::allocator<C>]’

8 : required from here

/opt/gcc-4.9.0/include/c++/4.9.0/bits/stl_list.h:114:71: error: no matching
function for call to ‘C::C(int, int)’

: __detail::_List_node_base(), _M_data(std::forward<_Args>(__args)...)

^

/opt/gcc-4.9.0/include/c++/4.9.0/bits/stl_list.h:114:71: note: candidates are:

3 : note: C::C()

struct C { int a, b; };

^

3 : note: candidate expects 0 arguments, 2 provided

3 : note: constexpr C::C(const C&)

3 : note: candidate expects 1 argument, 2 provided

3 : note: constexpr C::C(C&&)

3 : note: candidate expects 1 argument, 2 provided

Compilation failed


I suppose it should work without defining constructor for C.

Reply via email to