C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Make all data pointers intercompatible

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 27 Jan 2025 10:16:36 -0800
On Monday 27 January 2025 06:11:49 Pacific Standard Time Sebastian Wittmeier
via Std-Proposals wrote:
> There are Harvard architectures - separate program + data - e.g. Nvidia GPUs
> supporting modern C++.

And also microcontrollers. There was one that required an extra attribute for
data variables accessing ROM-stored constants (__progdata or something) but I
can't recall which one.

The C++ standard could require that
 sizeof(void*) == sizeof(void(*)())
by requiring that they are the larger of the two. I *think* POSIX requires
that and therefore it is effectively true for all supported C++ architectures.
Plus there's uintptr_t.

That does not mean that values stored in one can be used for another. For
example, attempting to read the instruction bytes from a function could lead
to unrelated garbage. Not that it was specified anyway, so you couldn't tell
whether you got the right information in the first place. Or it can still just
plain crash, because even von Neumann architectures could mark pages to be
executable-only, without read permissions.

The point being that there's nothing new you can do with the proposed
standardisation of pointer sizes. We may as well do it because it's true, but
why bother?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2025-01-27 18:16:39