@dalias @thephd thrd_exit works substantially the same here as pthread_cancel regarding the interaction between defer and -fexceptions. i guess i should have just pasted:
int main()
{
defer { printf("Deferred\n"); }
puts("Before exit");
thrd_exit(0);
puts("After exit");
}
With -fdefer-ts -fexceptions on at least Clang 22 and probably glibc outputs:
Before exit
Deferred