C++ Logo

std-proposals

Advanced search

Re: [std-proposals] User-Defined Trivial Constructors

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sun, 11 Jan 2026 17:46:59 -0500
On Sun, Jan 11, 2026 at 3:12 PM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On Sunday, 11 January 2026 16:27:41 Brasilia Standard Time Sebastian Wittmeier
> via Std-Proposals wrote:
> > However, if those types are not implicit-lifetime types, the compiler or C++
> > runtime or optimizer or some safety checker would perhaps need some hint
> > about the already started objects residing there.
> >
> >
> > From a practical standpoint, demanding the program to explicitly start the
> > lifetime (or a better operation like resuming or sharing the lifetime)
> > would perhaps be useful?
>
> I disagree. If I get a void pointer to a shared memory area and static_cast it
> to my type, it should be ok. As far as I can tell, it's no different than
> getting a pointer to an object whose lifetime was started by another thread in
> this program. If the latter is enough to the compiler, the former should too.

How could the system possibly *know* that it's OK? How is it supposed
to know the difference between a "shared memory area" and "something
that looks like a shared memory area but isn't shared with anybody"?
How could the system possibly know if something else actually started
the lifetime using the type you cast it to?

The difference with threading is that it's actually possible for that
information to exist. Everything is in the same process, so there's a
direct means of communicating that information from one area to
another (ie: using memory).

You're basically asking for it to just not care, for it to just assume
with no chance of verification or confirmation that whatever you're
doing in these arbitrary circumstances is fine.

> UBSan may need adjustments, but annotations for UBSan are acceptable. And
> UBSan can know the provenance via non-anonymous mmap() too.

Received on 2026-01-11 22:47:11