This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/68409] Garbage added to a map instead of object


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.)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]