[PATCH] fix singular iterator dereference in libstdc++ testcase 23_containers/list_modifiers.cc

Doug Gregor dgregor@apple.com
Mon Jun 9 22:33:00 GMT 2003


In the testcase 23_containers/list_modifiers.cc, the function test01() 
contains this block of code:

   list0101.pop_back();          // list should be [2 1]
   VERIFY(list0101.size() == 2);
   VERIFY(T::dtorCount() == 1);
   VERIFY(i->id() == 1);
   VERIFY(j->id() == 1); // INVALID
   VERIFY(k->id() == 1);

Prior to the pop_back() call, the list is [2 1 3]  and the iterators i 
and k, along with reverse_iterator j, point to the 1. However, the 
actual iterator that j stores (in j.current) points to the 3, which is 
invalidated by the pop_back() call, and therefore should not be 
dereferenced at the line marked INVALID. The same problem occurs again 
in the next block (j.current is still singular).

Note that the problem does not show up as a failure in normal test 
runs, presumably because the old node is still accessible in memory due 
to the pooling allocator.

Patch & changelog entry attached.

	Doug

-------------- next part --------------
A non-text attachment was scrubbed...
Name: list_modifiers_invalid.ChangeLog
Type: application/octet-stream
Size: 148 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20030609/47423a1a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list_modifiers_invalid.patch
Type: application/octet-stream
Size: 756 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20030609/47423a1a/attachment-0001.obj>
-------------- next part --------------



More information about the Gcc-patches mailing list