Date: Mon, 16 Feb 2026 02:13:13 +0100
Hi,
On 2026-02-15T19:00:38-0500, Halalaluyafail3 via Std-Proposals wrote:
> On Sat, Feb 14, 2026 at 4:51 PM Alejandro Colomar via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
[...]
> > Proposed wording
> > Based on N3783.
> >
> > 6.7.5 Function specifiers
> > @@ Constraints, p5+1
> > +A function declared with a <b>_Noreturn</b> function specifier
> > +shall not contain a return statement.
> >
> > 6.7.12.7 The noreturn and _Noreturn attributes
> > @@ Constraints, p2+1
> > +A function declared with a <b>noreturn</b> attribute
> > +shall not contain a return statement.
>
> I think it might be worth allowing the following:
>
> [[noreturn]]int foo();
> [[noreturn]]int bar(){
> return foo();//provably OK, because foo does not return
> }
Compilers currently diagnose that too:
alx_at_devuan:~/tmp$ cat nr.c
[[noreturn]] int foo(void);
[[noreturn]] int bar(void)
{
return foo();
}
int foo2(void);
int bar2(void)
{
return foo2();
}
alx_at_devuan:~/tmp$ gcc -S nr.c
nr.c: In function ‘bar’:
nr.c:4:16: warning: function declared ‘noreturn’ has a ‘return’ statement
4 | return foo();
| ^~~~~
alx_at_devuan:~/tmp$ gcc -S -std=c89 nr.c
nr.c: In function ‘bar’:
nr.c:4:16: warning: function declared ‘noreturn’ has a ‘return’ statement
4 | return foo();
| ^~~~~
I personally like the diagnostic even in that case, because otherwise it
might be confusing to a reader of the code (especially, since the
attribute might be in a header file, far from the code it's reading).
Have a lovely night!
Alex
>
> This is a pattern that is used, for example:
> https://www.lua.org/manual/5.5/manual.html#luaL_error though noreturn
> is not actually used here since C89 compatibility is intended.
On 2026-02-15T19:00:38-0500, Halalaluyafail3 via Std-Proposals wrote:
> On Sat, Feb 14, 2026 at 4:51 PM Alejandro Colomar via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
[...]
> > Proposed wording
> > Based on N3783.
> >
> > 6.7.5 Function specifiers
> > @@ Constraints, p5+1
> > +A function declared with a <b>_Noreturn</b> function specifier
> > +shall not contain a return statement.
> >
> > 6.7.12.7 The noreturn and _Noreturn attributes
> > @@ Constraints, p2+1
> > +A function declared with a <b>noreturn</b> attribute
> > +shall not contain a return statement.
>
> I think it might be worth allowing the following:
>
> [[noreturn]]int foo();
> [[noreturn]]int bar(){
> return foo();//provably OK, because foo does not return
> }
Compilers currently diagnose that too:
alx_at_devuan:~/tmp$ cat nr.c
[[noreturn]] int foo(void);
[[noreturn]] int bar(void)
{
return foo();
}
int foo2(void);
int bar2(void)
{
return foo2();
}
alx_at_devuan:~/tmp$ gcc -S nr.c
nr.c: In function ‘bar’:
nr.c:4:16: warning: function declared ‘noreturn’ has a ‘return’ statement
4 | return foo();
| ^~~~~
alx_at_devuan:~/tmp$ gcc -S -std=c89 nr.c
nr.c: In function ‘bar’:
nr.c:4:16: warning: function declared ‘noreturn’ has a ‘return’ statement
4 | return foo();
| ^~~~~
I personally like the diagnostic even in that case, because otherwise it
might be confusing to a reader of the code (especially, since the
attribute might be in a header file, far from the code it's reading).
Have a lovely night!
Alex
>
> This is a pattern that is used, for example:
> https://www.lua.org/manual/5.5/manual.html#luaL_error though noreturn
> is not actually used here since C89 compatibility is intended.
-- <https://www.alejandro-colomar.es>
Received on 2026-02-16 01:13:18
