std::vector(iterator, size_type, value_type) corrupts data
----------------------------------------------------------

                 Key: STDCXX-294
                 URL: http://issues.apache.org/jira/browse/STDCXX-294
             Project: C++ Standard Library
          Issue Type: Bug
          Components: 23. Containers
    Affects Versions: 4.1.2, 4.1.3
         Environment: all
            Reporter: Martin Sebor
            Priority: Critical


The program below aborts at runtime:

$ cat t.cpp && make t && ./t
#include <assert.h>
#include <vector>

int main()
{
    static const int a[] = { 1, 2, 3, 4, 5 };
    std::vector<int> v (a, a + sizeof a / sizeof *a);

    v.insert (v.begin () + 2, 2, -1);

    static const int b[] = { 1, 2, -1, -1, 3, 4, 5 };
    assert (v == std::vector<int>(b, b + sizeof b / sizeof *b));
}
gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG    
-D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/include 
-I/build/sebor/gcc-4.1.0-11s/include -I/build/sebor/dev/stdlib/examples/include 
 -pedantic -nostdinc++ -g  -W -Wall -Wcast-qual -Winline -Wshadow 
-Wwrite-strings -Wno-long-long  t.cpp
gcc t.o -o t  -L/build/sebor/gcc-4.1.0-11s/lib -lstd11s  -lsupc++ -lm
Assertion failed: v == std::vector<int>(b, b + sizeof b / sizeof *b), file 
t.cpp, line 12
Abort (core dumped)


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to