STL のコンテナとか std::string の thread safety

SGI STL のマニュアルには、

The SGI implementation of STL is thread-safe only in the sense that simultaneous accesses to distinct containers are safe, and simultaneous read accesses to to shared containers are safe. If multiple threads access a single container, and at least one thread may potentially write, then the user is responsible for ensuring mutual exclusion between the threads during the container accesses.

http://www.sgi.com/tech/stl/thread_safety.html

と書いてあって、昔の libstdc++ の FAQ には、

We currently use the same definition that SGI uses for their STL subset. However, the exception for read-only containers only applies to the STL components.

http://www.cs.huji.ac.il/~etsman/Docs/gcc-3.4-base/libstdc++/html/17_intro/howto.html

と書いてあるから read-only ならロック不要だったのだけれど、最新の FAQ (Frequently Asked Questions) には、その記載はなくなってるっぽい。

std::string については、上記 STL のマニュアルの中で、

On the other hand, this notion of thread-safety is stronger than that provided by reference-counted string implementations that try to follow the CD2 version of the draft standard. Such implementations require locking between multiple readers of a shared string.

と書いてあるけど、GCC 4.0.1 (on Leopard) に付属する std::string の実装見てると参照カウンタは _Atomic_word 型だから、同時リードは可能なんじゃないかという気がしてくる *1

ポータビリティ考えると全部ロック使うべき (あるいは複製をもつべき) って話なのかなー。どうなんだろ。

*1:c_str() の中で再アロケートとかもしてない