STL, string bug

Dima Volodin dvv@dvv.ru
Fri Apr 30 23:15:00 GMT 1999


"Beardsley, Jason" wrote:

> The reason I think it's in <string>, and not in the allocator, is that
> replacing the list<string> with a list<int> results in a working
> program.  That could be a faulty assumption, though.  Maybe it is a
> problem with the allocator, and only shows up when using lists of
> non-builtin types, large objects, or something along those lines.

The problem is with <string> - if you re-arrange your program something
like this:

    pthread_mutex_lock (.....);
    {
        string str ("........");
        .....
    }
    pthread_mutex_unlock (.....);

you'll also have a working program. A better news is that the latest STL
code from SGI doesn't try to do this naive copy-on-write thing in
<string> and works with your original code without any problem at all.

> Jason Beardsley

Dima




More information about the Gcc-bugs mailing list