This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/43014] map [] behaviour is inconsistent



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]