🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1281

Re: C: a question about scope automatics in C

#1281
From: Keith Thompson
Date: Mon, 02 Nov 2026 23:09
28 lines
2302 bytes
Ross Finlayson <ross.a.finlayson@gmail.com> writes:
> C: a question about scope automatics in C

No need to mention C in the subject (twice).  We know what newsgroup
we're in.

> Hello, I hope someone can tell me whether C may make
> for scope automatics any account of attaching side-effects
> to block-declared variables about scope-exit of automatics
> making for any way in C to attach behavior to scope-exit,
> or any way to make for when a variable goes out of scope
> (block-scope, or, function-scope) to make any account of
> cleanup of it.

FWIW, you could have probably said that more clearly with about a
third as many words.

You mentioned alloca() in a followup.  Memory allocated by alloca() is
deallocated on exit from the function, not on leaving a smaller scope.
And of course alloca() is non-standard (not even specified by POSIX).

There's a proposal for C2y, adding a new _Defer keyword.

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n4001.pdf

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Technical Details
Message-ID: <11cb56q$39nj8$2@kst.eternal-september.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail
References: <oOScndMmgZhYRXX3nZ2dnZfqnPGdnZ2d@giganews.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: C: a question about scope automatics in C
Date: Mon, 02 Nov 2026 15:09:14 -0800
Organization: None to speak of
Lines: 28
Message-ID: <11cb56q$39nj8$2@kst.eternal-september.org>
References: <oOScndMmgZhYRXX3nZ2dnZfqnPGdnZ2d@giganews.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Mon, 02 Nov 2026 23:09:15 +0000 (UTC)
Injection-Info: kst.eternal-september.org;
	logging-data="3464808"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18H2M2l5bgsdNBnXBS6SF3R"; posting-host="b2b9691d5f86313d524e66216e8e116e"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:koXQSHpxBRSRG2cavivklIqEjS4= sha256:MnoKe0quOraljn7punrvkF9I7rW1MQQX9BHQtrCraaM=
	sha1:K/btOkK3mijiLqpurB5MgbqG9h4= sha256:DJ5U8teVRhFjQqUhROKT9k9T0jr2QJ/6Cn70bfNa5hc=