C++ Logo


Advanced search

Re: [std-proposals] C++ never had a compiler without a stack

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Mon, 14 Aug 2023 19:43:35 +0100
On Mon, Aug 14, 2023 at 4:21 PM Thiago Macieira <thiago_at_[hidden]> wrote:
> And what would such function be used for? Please give three different use-cases
> or at least one very strong one that couldn't otherwise be implemented without
> it.

On Page 6 of my paper on Named Return Value Optimisation:

I place a UUID on the stack alongside data which is to be retrieved
later. Basically it's a universal way of implementing thread-local
storage. So if I want to have a thread_local variable called 'abc',
then my strategy is that at every thread entry point, I place the UUID
on the stack beside the four bytes 'a' 'b' 'c' '\0' followed by the
bytes denoting its value. Then later in the program's execution I can
walk the stack backwards til I find the UUID and then I have access to
my thread-local data.

I can use the function "alloca" at runtime to create more thread-local

But more to the point: We should have control of stuff in C++. Every
C++ platform has a stack, so give us access to it. Just because I can
only come up with one good use for it now doesn't mean someone else
won't come up with a use for it later.

Received on 2023-08-14 18:43:47