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

             Bug #: 54392
           Summary: [4.6/4.7/4.8 Regression] std::string::append() fails
                    to update length
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: r...@gcc.gnu.org


#include <string>
#include <cassert>

int main()
{
    std::string s1, s2;
    s1.assign(s2.c_str(), 1);
    assert( s1.size() == 1 );
}

This test passes with G++ 4.4, but in 4.5 and later string::assign(const char*,
size_type) doesn't mutate the string but tries to work in-place on the empty
rep, then tries (and fails) to set the length of the empty rep to 1.

Reply via email to