[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#523690: marked as done (std::map<>::erase(map.end()) should be a no-op)



Your message dated Sun, 12 Apr 2009 14:32:40 +0200
with message-id <20090412123238.GA29567@minet.uni-jena.de>
and subject line Re: Bug#523690: std::map<>::erase(map.end()) should be a no-op
has caused the Debian Bug report #523690,
regarding std::map<>::erase(map.end()) should be a no-op
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
523690: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=523690
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: libstdc++6
Version: 4.3.3-3
Severity: normal

Hello,

The std::map::erase(iterator) method in libstdc++6 cannot deal with the case 
that it is called with the end() iterator:

$ cat foo.cc
#include <map>
int main(int, char**) {
  std::map<int,int> m;
  m[1] = 2;
  m[3] = 4;
  m.erase(m.find(5)); // 5 not found, so find() returns end()
}
$ g++ -O2 -Wall -o foo foo.cc
$ $ ./foo 
*** glibc detected *** ./foo: free(): invalid pointer: 0xbfc25c24 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6[0xb7cd81e4]
[snip backtrace]

I do not have a copy of the standard itself, but in C++ 3rd ed, section 
17.4.1.7, page 489, Stroustrup says simply "Erasing end() is harmless", which 
I interpret as "it has no effect".

Cheers,

  Richard

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.28.7
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libstdc++6 depends on:
ii  gcc-4.3-base                  4.3.3-3    The GNU Compiler Collection (base 
ii  libc6                         2.9-4      GNU C Library: Shared libraries
ii  libgcc1                       1:4.3.3-3  GCC support library

libstdc++6 recommends no packages.

libstdc++6 suggests no packages.

-- no debconf information



--- End Message ---
--- Begin Message ---
On Sun, Apr 12, 2009 at 12:07:54AM +0200, Richard Atterer wrote:
> The std::map::erase(iterator) method in libstdc++6 cannot deal with the case 
> that it is called with the end() iterator:
>
> [...]
> 
> I do not have a copy of the standard itself, but in C++ 3rd ed, section 
> 17.4.1.7, page 489, Stroustrup says simply "Erasing end() is harmless", which 
> I interpret as "it has no effect".

It's a bug in the book. See
http://www.research.att.com/~bs/3rd_printing11.html:

pg 489 replace "Erasing end() is harmless." by "A call m.erase(b,e)
where e is m.end() is harmless (provided b refers to an element of m
or is m.end()). However, a call m.erase(p) where p is m.end() is a
serious error that could corrupt the container." 

  Falk


--- End Message ---

Reply to: