Path: csiph.com!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Effect of CPP tags Date: Mon, 08 Jan 2024 10:32:07 -0800 Organization: None to speak of Lines: 33 Message-ID: <871qarr80o.fsf@nosuchdomain.example.com> References: <%cFlN.140487$xHn7.115393@fx14.iad> <87jzomrvh8.fsf@nosuchdomain.example.com> <878r52rljn.fsf@nosuchdomain.example.com> <874jfpstyc.fsf@nosuchdomain.example.com> <87sf38r9bu.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="f909ce6842d964f6deb0fc108ae5e13b"; logging-data="1723433"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19MLJjM3OI2w3kCrWy+1yYp" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:4I1qH4t1AF1IaE3+bUCY9uzjp4U= sha1:mb3KpmXE4JgXsyR98iEkomKe2Wc= Xref: csiph.com comp.lang.c:379930 David Brown writes: > On 08/01/2024 02:32, Bart wrote: [...] >> (BTW why did VLAs become optional from C11?) > > I don't know for sure. But I do know that not all C implementations > use a stack, and for some targets a "true VLA" (as distinct from a VLA > where the size is known at compile time) would be extremely > inefficient to implement. It is possible that this has something to > do with it. I'm skeptical that that's the reason. Almost all C implementations do use a "stack", in the sense of a contiguously allocated region of memory in which automatic objects are allocated, with addresses uniformly increasing or decreasing for new allocations. (All C implementations use a "stack" in the sense of a last-in/first-out data structure.) I'm not aware that any implementers of non-stack implementations objected to VLAs. For that matter, I don't know why VLAs would be extremely inefficient in such an implementation. They need to have the ability to allocate new stack frames anyway, and determining the allocation size at run time shouldn't be a huge burden. I've seen suggestions that the intent was to make it possible to create conforming C implementations for small embedded processors. That might make sense, but it could have been addressed by making VLAs optional only for freestanding implementations. I think Microsoft has chosen not to implement VLAs in their C compiler. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Medtronic void Void(void) { Void(); } /* The recursive call of the void */