[Bug c++/78420] std::less<T*> is not a total order with -O2 enabled
tomaszkam at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Nov 18 15:14:00 GMT 2016
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.
More information about the Gcc-bugs
mailing list