This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/47628] non-compliant C++0x erase methods on STL containers
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 7 Feb 2011 17:17:58 +0000
- Subject: [Bug libstdc++/47628] non-compliant C++0x erase methods on STL containers
- Auto-submitted: auto-generated
- References: <bug-47628-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47628
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-02-07 17:17:54 UTC ---
Here's a reduced form of the code, which works with GCC 4.5 and earlier, but is
ambiguous with 4.6
#include <map>
struct Key
{
Key() { }
Key(const Key&) { }
template<typename T>
Key(const T&)
{ }
bool operator<(const Key&) const;
};
typedef std::map<Key, int> Map;
void f()
{
Map m;
(void) m[Key()];
Map::iterator i = m.begin();
m.erase(i);
}
I'm not sure if the code is valid or not (Paolo?)
In C++0x mode the ambiguity is in the user code, because non-const iterator can
be converted to const_iterator or key_type (I believe this behaviour is
required by the standard)
In C++98 mode it's in the library code when calling _M_t.erase - this is a
regression. Paolo, should _Rb_tree::erase take a non-const iterator in c++98
mode? That's what map::erase passes it.