This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/43014] map [] behaviour is inconsistent
- From: "paolo dot carlini at oracle dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Feb 2010 23:20:41 -0000
- Subject: [Bug libstdc++/43014] map [] behaviour is inconsistent
- References: <bug-43014-18766@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from paolo dot carlini at oracle dot com 2010-02-09 23:20 -------
The "surprising" behavior is ultimately due to the fact that our string is
reference counted, thus 'string aux = sElement' is a shallow copy, but then,
when sElement = "ab3" is performed a deep copy takes place and the sElement
object allocates a *new* buffer of memory to host the "ab3" chars, at a new,
different memory location (thus "not found"). On the other hand, the new
allocation does not happen when aux = sElement is missing, because in this case
the address of the first char of sElement remains stable (thus "found").
In any case, the current C++03 Standard explicitly allows for reference counted
implementations, thus the outcome of the first find here is undefined.
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43014