public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/34524] New: Use of invalidated std::string iterators not caught in debug mode
@ 2007-12-18 19:43 gcc-bugzilla at contacts dot eelis dot net
2007-12-18 20:00 ` [Bug libstdc++/34524] " pcarlini at suse dot de
2007-12-18 20:16 ` gcc-bugzilla at contacts dot eelis dot net
0 siblings, 2 replies; 3+ messages in thread
From: gcc-bugzilla at contacts dot eelis dot net @ 2007-12-18 19:43 UTC (permalink / raw)
To: gcc-bugs
In the following code, libstdc++'s debug mode does not catch the use of a
potentially invalidated std::string iterator.
#define _GLIBCXX_DEBUG
#define _GLIBCXX_DEBUG_PEDANTIC
#include <string>
#include <vector>
#include <iostream>
int main()
{
typedef std::string S;
S s (3, 'x');
S::iterator i = s.begin(); ++i;
s.push_back('y');
std::cout << *i << std::endl; // just outputs 'x'
}
Since the push_back may invalidate i (per 21.3 para 5, 4th item), libstdc++'s
debug mode should emit an error and abort.
If I change the typedef to std::vector<char>, then the indicated line /does/
cause libstdc++ to emit an error ("attempt to dereference a singular iterator")
and abort.
--
Summary: Use of invalidated std::string iterators not caught in
debug mode
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc-bugzilla at contacts dot eelis dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34524
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/34524] Use of invalidated std::string iterators not caught in debug mode
2007-12-18 19:43 [Bug libstdc++/34524] New: Use of invalidated std::string iterators not caught in debug mode gcc-bugzilla at contacts dot eelis dot net
@ 2007-12-18 20:00 ` pcarlini at suse dot de
2007-12-18 20:16 ` gcc-bugzilla at contacts dot eelis dot net
1 sibling, 0 replies; 3+ messages in thread
From: pcarlini at suse dot de @ 2007-12-18 20:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pcarlini at suse dot de 2007-12-18 20:00 -------
Did you read the documentation?
http://gcc.gnu.org/onlinedocs/libstdc++/ext/debug_mode.html
in a nutshell, our design doesn't provide safe iterators for basic_string.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |WONTFIX
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34524
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/34524] Use of invalidated std::string iterators not caught in debug mode
2007-12-18 19:43 [Bug libstdc++/34524] New: Use of invalidated std::string iterators not caught in debug mode gcc-bugzilla at contacts dot eelis dot net
2007-12-18 20:00 ` [Bug libstdc++/34524] " pcarlini at suse dot de
@ 2007-12-18 20:16 ` gcc-bugzilla at contacts dot eelis dot net
1 sibling, 0 replies; 3+ messages in thread
From: gcc-bugzilla at contacts dot eelis dot net @ 2007-12-18 20:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from gcc-bugzilla at contacts dot eelis dot net 2007-12-18 20:16 -------
My apologies.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34524
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-12-18 20:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-18 19:43 [Bug libstdc++/34524] New: Use of invalidated std::string iterators not caught in debug mode gcc-bugzilla at contacts dot eelis dot net
2007-12-18 20:00 ` [Bug libstdc++/34524] " pcarlini at suse dot de
2007-12-18 20:16 ` gcc-bugzilla at contacts dot eelis dot net
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).