C++ Logo


Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 15 Aug 2023 07:17:26 -0700
On Tuesday, 15 August 2023 06:56:20 PDT Julien Villemure-Fréchette via Std-
Proposals wrote:
> I think the intent of alloca in Posix and VLA in C was specifically to have
> automatic cleanup semantics for objects with block scoped lifetime. C++
> already has the language feature that makes it possible to ensure proper
> cleanup at end of scope, so the need for VLA evaporates. If you look
> closely, the C language doesn't seem to make any mention of the stack in
> the specification of VLAs, I think a pair of malloc/free may be a possible
> implementation.

The difference is that alloca() has determinstic runtime (provided it doesn't
overflow), wheras malloc() cannot be guaranteed to.

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-08-15 14:17:28