On Wed, 8 Jul 2026, navi wrote:

> From: "navi" <[email protected]>
> 
> based on the technical specification 25755[1] as an extension
> 
> _Defer is provided as a keyword if gnu extensions are enabled, and
> stddefer.h provided a macro for the 'defer' spelling
> 
> deferred statements execute at the end of the scope they're added on,
> similar to the cleanup attribute, and they have much of the same
> constraints as statement expressions, with added limitation that no
> local jump shall jump over a defer statement, nor shall return, break,
> and continue, jump out of one
> 
> 1: https://open-std.org/JTC1/SC22/WG14/www/docs/n3734.pdf

That's a pretty old version.  Does this implementation correspond to the 
current version N3928?  (In particular, the change (made in v5; the 
version you reference is v4, and the current version is v6) that it's 
guaranteed that leaving execution of the scope of a defer by a noreturn 
function call, such as longjmp or exit, or a signal, does not execute the 
deferred block, when previously it was implementation-defined whether this 
happens.  Note that the description of Example 3 hasn't been properly 
updated for that; to be corrected in the ballot draft.)

Since we allow mixed-language code to throw exceptions (e.g. C++) across C 
code built with -fexceptions, it would be a good idea also to have test 
coverage for how this feature interacts with exceptions.  And I think the 
GCC manual should document how the feature interacts with relevant GNU 
extensions (the cleanup attribute - you already have a test using that - 
and throwing exceptions across C code, at least).

-- 
Joseph S. Myers
[email protected]

Reply via email to