Issue 1065: More issues with noreturn

Authors: Jay Ghiron
Date: 2026-05-21
Submitted against: C23
Status: Open
Cross-references: 1037

All of the following questions will be referencing:

The first declaration of a function shall specify the noreturn attribute if any declaration of that function specifies the noreturn attribute. If a function is declared with the noreturn attribute in one translation unit and the same function is declared without the noreturn attribute in another translation unit, the behavior is undefined.

(C23 6.7.13.7 "The noreturn and _Noreturn attributes" paragraph 3.)

Question 1

Do the following two translation units cause undefined behavior?

/* TU 1*/
[[noreturn]]void foo();
/* TU 2 */
[[noreturn]]void foo();
void foo();

The second translation unit in isolation is fine, but the first translation unit declares the function with noreturn and the second translation unit declares it without noreturn in its second declaration. Therefore it appears that redeclarations are required to use noreturn too if any other translation unit declares the function, though that does not seem intended.

Question 2

For standard library functions that are specified with noreturn, is it required that manual declarations specify noreturn too? For example:

void exit(int);/* OK in C11, UB in C23? */
int main(){
exit(0);
}

If the answer to question one is that those translation units are not valid, then this would also apply to redeclarations after including the appropriate standard header:

#include<stdlib.h>
void exit(int);/* is noreturn needed here? */

Question 3

If the answer to question two is that such functions need not be manually declared with noreturn, must they be manually declared without noreturn?

Some existing implementations (for example newlib) define noreturn functions introduced in C11 using the _Noreturn function specifier instead of the noreturn attribute, even in C23 which precludes using noreturn attributes.