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



             Bug #: 56437

           Summary: basic_string assumes that allocators are

                    default-constructible

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: libstdc++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: tneum...@pi3.informatik.uni-mannheim.de





Created attachment 29531

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29531

example



The empty-string optimization of basic_string assumes that allocators are

default constructible. While this used to be the case in C++98, it is no longer

true in C++11, as now allocators are allowed to have state.



Consider the attached example program. Compiling with



g++ -std=c++11 -c t.cpp



produces an error message, even though it should compile fine. The problem is

the the "_S_construct" calls "_Alloc()", which does not exist.



Note that the C++11 standard does not require default constructors. (Section

17.6.3.5, Table 28). In particular, the SimpleAllocator example from Section

17.6.3.5 would trigger the same bug, too.

Reply via email to