This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/21334] Lack of Posix compliant thread safety in std::basic_string
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 31 May 2012 16:42:27 +0000
- Subject: [Bug libstdc++/21334] Lack of Posix compliant thread safety in std::basic_string
- Auto-submitted: auto-generated
- References: <bug-21334-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21334
--- Comment #47 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-31 16:42:27 UTC ---
21.4.1 [string.require] says that the non-const forms of operator[], at, front,
back, begin, rbegin, end and rend may not invalidate references, pointers and
iterators (so must not reallocate or modify the string)
This example shows that requirement is not met:
std::string s("str");
const char* p = s.data();
{
std::string s2(s);
(void) s[0];
}
std::cout << *p << '\n'; // p is dangling
Also the copy constructor requirements in Table 64 require the new object to
have a copy of the data. I think there are other reasons too.