Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Syntax-wise it is a function specifier and may in theory appear everywhere where inline (or rather the syntax item function-specifier:) can appear, since the standard doesn't say otherwise. Though ...
Answer
#1: Initial revision
Syntax-wise it is a function specifier and may in theory appear everywhere where `inline` (or rather the syntax item _function-specifier:_) can appear, since the standard doesn't say otherwise. Though of course it would be nonsense to declare `_Noreturn` together with a return type and a compiler failing to warn against such would be a low quality of implementation. Though I believe the "recommended practice" part is a "code coverage" recommendation, as in having the compiler diagnose if any execution path inside the function could lead to it returning, rather than just checking if it is declared with a return type other than `void`. This is just a recommendation though, so it isn't normative or required. The only normative text here is 6.7.4/8 and violating it would lead to undefined behavior. Regarding pthread callbacks I'm not sure what benefit it would yield other than the compiler perhaps skipping some return instruction and saving a few bytes of code size. Arguably, a thread function which never returns but has to be clobbered to death with brute force is incorrectly designed - threads should always be able to exist gracefully on their own upon the reception of a event/semaphore etc. Never returning would potentially also break `pthread_join`, in case it expects a certain calling convention but the callback deviates from the expected `void* f(void*)` format (by not stacking the return pointer etc). As for Clang specifically, I very much doubt it is capable of giving warnings about `_Noreturn`. Clang is as far as I know still completely broken in this regard and unable to follow the 6.7.4 recommendation since it is unable to correctly generate execution paths to begin with, let alone diagnose them. See this compiler bug: [How do I make an infinite empty loop that won't be optimized away?](https://stackoverflow.com/questions/59925618/how-do-i-make-an-infinite-empty-loop-that-wont-be-optimized-away)