Author: H. Vetinari
Created at: 2025-11-21 03:25
Number: 190
Clean content: Neil Schemenauer: I’ve heard that the C language standard might eventually be getting something like __attribute__((cleanup(...))) . It’s probably going to be decades before CPython could actually rely on C compilers supporting that. This is the defer proposal, which currently exists as a TS (like a branch of the C standard). Here’s an overview of the thing (and the procedural reasons for the TS) in blog post format. Clang has a mostly ready PR for this [1] . The GCC patch set is at v5 AFAICT. Long story short, this should be available in compilers relatively soon [2] and may make it into C2y if people like the feature and let people on the committee know. However you’re likely right about the timelines. Anything before 2040 for broad availability (i.e. defer as part of the standard, not a TS, and implemented across all major compilers present on LTS distros) would be wildly optimistic IMO [3] . Who knows how the world (and CPython) looks like by then… check out the number of reactions as a barometer for people’s interest in this ↩︎ MSVC’s C standard conformance has been horrible since C99; you’d be better off using clang-cl on windows than wait for MSVC on anything. They still haven’t gotten C99 or C11 finished, and ~zero for C23. ↩︎ On the other hand, if people were willing to replace MSVC with clang-cl and rely on -fdefer-ts , you could probably do it in 5 years, assuming the benefits are so substantial that this would be worth it. ↩︎
