This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/68409] Garbage added to a map instead of object
- From: "adrian.wielgosik at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 20 Nov 2015 11:33:00 +0000
- Subject: [Bug c++/68409] Garbage added to a map instead of object
- Auto-submitted: auto-generated
- References: <bug-68409-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68409
Adrian Wielgosik <adrian.wielgosik at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |adrian.wielgosik at gmail dot com
--- Comment #2 from Adrian Wielgosik <adrian.wielgosik at gmail dot com> ---
Your operator< doesn't seem to satisfy strict weak ordering. Once I rewrote it
to a basic but safer version:
bool operator< (const chave& lhs, const chave& rhs) {
if(lhs.numeros_ord != rhs.numeros_ord)
return lhs.numeros_ord < rhs.numeros_ord;
return lhs.estrelas_ord < rhs.estrelas_ord;
}
It seems to work fine to me.
(Also, when testing with clang/GCC, try using AddressSanitizer or valgrind,
you'll have a better chance of catching illegal memory accesses.)