Date: Wed, 30 Nov 2022 20:36:41 +0100
Hello,
Il 30/11/22 20:30, Vladimir Grigoriev via Std-Discussion ha scritto:
> So is the behavior is undefined or unspecified when there are compared
> two pointers to different objects that are not elements of the
> same array. as for example
> &x < &y
This is
https://eel.is/c++draft/expr.rel#4
"neither pointer is required to compare greater than the other".
Which maybe means it's not UB to merely call the operator, but the
result is useless; and if you feed such an operator into something with
preconditions (like a sorting algorithm, that needs a strict weak order)
then you trigger library UB.
HTH,
Il 30/11/22 20:30, Vladimir Grigoriev via Std-Discussion ha scritto:
> So is the behavior is undefined or unspecified when there are compared
> two pointers to different objects that are not elements of the
> same array. as for example
> &x < &y
This is
https://eel.is/c++draft/expr.rel#4
"neither pointer is required to compare greater than the other".
Which maybe means it's not UB to merely call the operator, but the
result is useless; and if you feed such an operator into something with
preconditions (like a sorting algorithm, that needs a strict weak order)
then you trigger library UB.
HTH,
-- Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
Received on 2022-11-30 19:36:44