This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/50093] New: [4.6 Regression] STL containers of non-default-constructible classes fail under -std=c++0x


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

             Bug #: 50093
           Summary: [4.6 Regression] STL containers of
                    non-default-constructible classes fail under
                    -std=c++0x
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: andersk@mit.edu


This code builds with âg++-4.5â, âg++-4.5 -std=c++0xâ, and âg++-4.6â, but fails
with âg++-4.6 -std=c++0xâ:

#include <vector>
class Foo {
    Foo(int) {}
};
template class std::vector<Foo>;
int main() {return 0;}

$ g++-4.6 -std=c++0x foo.cc
In file included from /usr/include/c++/4.6/vector:63:0,
                 from foo.cc:1:
/usr/include/c++/4.6/bits/stl_construct.h: In function âvoid
std::_Construct(_T1*, _Args&& ...) [with _T1 = Foo, _Args = {}]â:
/usr/include/c++/4.6/bits/stl_uninitialized.h:481:3:   instantiated from
âstatic void
std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator,
_Size) [with _ForwardIterator = Foo*, _Size = long unsigned int, bool
_TrivialValueType = false]â
/usr/include/c++/4.6/bits/stl_uninitialized.h:529:7:   instantiated from âvoid
std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator
= Foo*, _Size = long unsigned int]â
/usr/include/c++/4.6/bits/stl_uninitialized.h:589:7:   instantiated from âvoid
std::__uninitialized_default_n_a(_ForwardIterator, _Size, std::allocator<_Tp>&)
[with _ForwardIterator = Foo*, _Size = long unsigned int, _Tp = Foo]â
/usr/include/c++/4.6/bits/stl_vector.h:1134:2:   instantiated from âvoid
std::vector<_Tp, _Alloc>::_M_default_initialize(std::vector<_Tp,
_Alloc>::size_type) [with _Tp = Foo, _Alloc = std::allocator<Foo>,
std::vector<_Tp, _Alloc>::size_type = long unsigned int]â
foo.cc:5:21:   instantiated from here
/usr/include/c++/4.6/bits/stl_construct.h:76:7: error: no matching function for
call to âFoo::Foo()â
/usr/include/c++/4.6/bits/stl_construct.h:76:7: note: candidates are:
foo.cc:3:5: note: Foo::Foo(int)
foo.cc:3:5: note:   candidate expects 1 argument, 0 provided
foo.cc:2:7: note: constexpr Foo::Foo(const Foo&)
foo.cc:2:7: note:   candidate expects 1 argument, 0 provided
foo.cc:2:7: note: constexpr Foo::Foo(Foo&&)
foo.cc:2:7: note:   candidate expects 1 argument, 0 provided


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]