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++/78420] std::less<T*> is not a total order with -O2 enabled


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78420

--- Comment #3 from Tomasz Kamiński <tomaszkam at gmail dot com> ---
> I don't see this as prohibiting the transformation.  The standard seems to be saying that they might or might not compare as equal, which presumably depends on how variables are laid out in memory.  The optimization seems wrong to me.

But, the code snippet is not using == on this pointer, but std::less
specialization that is required to form total order, but in the attached
scenario as not because for p and b nor of following hold:
1) r(p, b)
2) r(b, p)
3) b is same as p (!r(p, b) && !r(b, p))
Which proves that r is not an total order. So the guarantee on the less<T*> is
no longer provided.

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