C++ Logo

std-discussion

Advanced search

Re: Relational operators with using pointers.

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Fri, 2 Dec 2022 23:47:22 +0000
On Fri, 2 Dec 2022, 17:51 Lénárd Szolnoki via Std-Discussion, <
std-discussion_at_[hidden]> wrote:

> Hi,
>
> On 2 December 2022 17:06:31 GMT, Edward Catmur via Std-Discussion <
> std-discussion_at_[hidden]> wrote:
> >
> >> Another could be freedom for compilers how they will layout stack
> >> > variables as you are not allowed to compare addresses of them.
> >
> >
> >I don't think undefined vs. unspecified makes much of a difference here;
> >the compiler could just always return false to every comparison between
> >pointers to automatic variables and you wouldn't be able to learn anything
> >about the layout.
>
> I don't think this is feasibly implementable. Consider `identity(&a) <
> identity(&b)`, where `identity` is opaque to the compiler.
>

Or just using intptr_t. But the compiler doesn't have to give consistent
answers to any of these.

Having said that an unspecified comparison still doesn't restrict the stack
> layout in any way.
>

Right, yeah.


> Cheers,
> Lénárd
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>

Received on 2022-12-02 23:47:36