C++ Logo


Advanced search

Re: Relational operators with using pointers.

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Thu, 01 Dec 2022 19:58:26 +0300
It is unclear why such a difference between C and c++ was introduced.
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
>Среда, 30 ноября 2022, 22:46 +03:00 от Jens Maurer via Std-Discussion <std-discussion_at_[hidden]>:
>On 30/11/2022 20.30, Vladimir Grigoriev via Std-Discussion wrote:
>> In the C Standard there is explicitly written that when two pointers do not point to elements of the same array (including the element or one pass the last element) the behavior is undefined:
>> «In all other cases, the behavior is undefined.»
>> However in the C++ 20 Standard I do not see such a phrase. 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
>See expr.rel p5. In this case, neither pointer is required to compare
>greater than the other by p4, so the result of the relational operators
>is unspecified.
>Std-Discussion mailing list

Received on 2022-12-01 16:58:34