libstdc++/1853: <deque> deallocates unowned memory within .pop_back()
pme@gcc.gnu.org
pme@gcc.gnu.org
Wed Jan 2 21:00:00 GMT 2002
Synopsis: <deque> deallocates unowned memory within .pop_back()
State-Changed-From-To: analyzed->closed
State-Changed-By: pme
State-Changed-When: Wed Jan 2 21:00:36 2002
State-Changed-Why:
Like jdennett says, this is undefined behavior. To be
strictly portable and correct, users should check for
!x.empty() before removing elements from a container x.
By default we shouldn't do sanity checking, I believe.
The overhead imposed could be significant when pop_back
is being called in a loop (which is what a double-ended
queue could easily be used for). The same holds for other
functions which behave badly when invoked in undefined
situations. The penalty would be imposed for users which
are correctly checking for empty containers, and would
then be redundant.
For 3.2 I hope to add some kind of super-safe debugging
mode to the library. Speed and efficiency would go
down the toilet, but we could catch cases like these.
The guiding documentation for users would be: if your
code works with this mode on, and it breaks without it,
then you're doing something undefined.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=1853
More information about the Gcc-bugs
mailing list