Date: Thu, 1 Dec 2022 17:27:20 +0000
On Thu, 1 Dec 2022 at 16:58, Vladimir Grigoriev via Std-Discussion <
std-discussion_at_[hidden]> wrote:
> It is unclear why such a difference between C and c++ was introduced.
>
Yes. If it helps, the difference has existed since standardization: the
comparison is undefined in C89 and unspecified in C++98, so it might be
tricky to discover the rationale.
Perhaps you could ask SG22 whether they know the cause of the divergence,
and whether they're interested in resolving it.
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.
>
> Jens
>
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> <http:///compose?To=Std%2dDiscussion_at_[hidden]>
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
>
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
std-discussion_at_[hidden]> wrote:
> It is unclear why such a difference between C and c++ was introduced.
>
Yes. If it helps, the difference has existed since standardization: the
comparison is undefined in C89 and unspecified in C++98, so it might be
tricky to discover the rationale.
Perhaps you could ask SG22 whether they know the cause of the divergence,
and whether they're interested in resolving it.
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.
>
> Jens
>
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> <http:///compose?To=Std%2dDiscussion_at_[hidden]>
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
>
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
Received on 2022-12-01 17:27:33