GNU bug report logs - #78903
[PATCH] ISO C99 does not support _Noreturn

Previous Next

Package: emacs;

Reported by: Helmut Eller <eller.helmut <at> gmail.com>

Date: Thu, 26 Jun 2025 07:22:01 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

To reply to this bug, email your comments to 78903 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Thu, 26 Jun 2025 07:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Helmut Eller <eller.helmut <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 26 Jun 2025 07:22:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Helmut Eller <eller.helmut <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] ISO C99 does not support _Noreturn
Date: Thu, 26 Jun 2025 09:20:51 +0200
[Message part 1 (text/plain, inline)]
Tags: patch

When I use gcc 14 with -std=gnu99 -Wpedantic I get lots of warnings of
the form

 warning: ISO C99 does not support ‘_Noreturn’ [-Wpedantic].

To avoid those warnings, I propose to use __attribute__ ((__noreturn__))
instead.


[0001-Don-t-use-_Noreturn-with-GCC-unless-__STDC_VERSION__.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Thu, 26 Jun 2025 07:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 78903 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Helmut Eller <eller.helmut <at> gmail.com>,
 Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 78903 <at> debbugs.gnu.org
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Thu, 26 Jun 2025 10:51:39 +0300
> From: Helmut Eller <eller.helmut <at> gmail.com>
> Date: Thu, 26 Jun 2025 09:20:51 +0200
> 
> When I use gcc 14 with -std=gnu99 -Wpedantic I get lots of warnings of
> the form
> 
>  warning: ISO C99 does not support ‘_Noreturn’ [-Wpedantic].

Why did you use -Wpedantic?  The Emacs build doesn't use that, and for
a good reason.

> To avoid those warnings, I propose to use __attribute__ ((__noreturn__))
> instead.

We have already a portable solution for _Noreturn, see src/config.in.
We could modify it if needed, but I'm not sure we should try straying
too far from what we have (which works), definitely not for the
benefit of "-Wpedantic".

Paul, WDYT?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Thu, 26 Jun 2025 08:10:03 GMT) Full text and rfc822 format available.

Message #11 received at 78903 <at> debbugs.gnu.org (full text, mbox):

From: Helmut Eller <eller.helmut <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78903 <at> debbugs.gnu.org, Paul Eggert <eggert <at> cs.ucla.edu>
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Thu, 26 Jun 2025 10:08:54 +0200
On Thu, Jun 26 2025, Eli Zaretskii wrote:

>> From: Helmut Eller <eller.helmut <at> gmail.com>
>> Date: Thu, 26 Jun 2025 09:20:51 +0200
>> 
>> When I use gcc 14 with -std=gnu99 -Wpedantic I get lots of warnings of
>> the form
>> 
>>  warning: ISO C99 does not support ‘_Noreturn’ [-Wpedantic].
>
> Why did you use -Wpedantic?

To get warnings when I use a non-C99 feature.  Emacs' C code should be
written in C99.  It would be easier to follow that rule it were checked
automatically.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Thu, 26 Jun 2025 08:24:01 GMT) Full text and rfc822 format available.

Message #14 received at 78903 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Helmut Eller <eller.helmut <at> gmail.com>
Cc: 78903 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Thu, 26 Jun 2025 11:23:10 +0300
> From: Helmut Eller <eller.helmut <at> gmail.com>
> Cc: Paul Eggert <eggert <at> cs.ucla.edu>,  78903 <at> debbugs.gnu.org
> Date: Thu, 26 Jun 2025 10:08:54 +0200
> 
> On Thu, Jun 26 2025, Eli Zaretskii wrote:
> 
> >> From: Helmut Eller <eller.helmut <at> gmail.com>
> >> Date: Thu, 26 Jun 2025 09:20:51 +0200
> >> 
> >> When I use gcc 14 with -std=gnu99 -Wpedantic I get lots of warnings of
> >> the form
> >> 
> >>  warning: ISO C99 does not support ‘_Noreturn’ [-Wpedantic].
> >
> > Why did you use -Wpedantic?
> 
> To get warnings when I use a non-C99 feature.  Emacs' C code should be
> written in C99.  It would be easier to follow that rule it were checked
> automatically.

AFAIK, Emacs is written in C99 with extensions.

Can you tell why the definition of _Noreturn in src/config.in doesn't
work for you?  AFAIU, it exactly defines _Noreturn to use
__attribute__ ((__noreturn__)), but I'm probably missing something.
is the problem that you use clang, and config.in currently doesn't
cater to that?  If so, the change should be in config.in, I think.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Thu, 26 Jun 2025 08:41:02 GMT) Full text and rfc822 format available.

Message #17 received at 78903 <at> debbugs.gnu.org (full text, mbox):

From: Helmut Eller <eller.helmut <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78903 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Thu, 26 Jun 2025 10:40:47 +0200
On Thu, Jun 26 2025, Eli Zaretskii wrote:

>> From: Helmut Eller <eller.helmut <at> gmail.com>
>> Cc: Paul Eggert <eggert <at> cs.ucla.edu>,  78903 <at> debbugs.gnu.org
>> Date: Thu, 26 Jun 2025 10:08:54 +0200
>> 
>> On Thu, Jun 26 2025, Eli Zaretskii wrote:
>> 
>> >> From: Helmut Eller <eller.helmut <at> gmail.com>
>> >> Date: Thu, 26 Jun 2025 09:20:51 +0200
>> >> 
>> >> When I use gcc 14 with -std=gnu99 -Wpedantic I get lots of warnings of
>> >> the form
>> >> 
>> >>  warning: ISO C99 does not support ‘_Noreturn’ [-Wpedantic].
>> >
>> > Why did you use -Wpedantic?
>> 
>> To get warnings when I use a non-C99 feature.  Emacs' C code should be
>> written in C99.  It would be easier to follow that rule it were checked
>> automatically.
>
> AFAIK, Emacs is written in C99 with extensions.

It would still be easier if the somewhat arbitrary set of extensions
would be checked automatically.

> Can you tell why the definition of _Noreturn in src/config.in doesn't
> work for you?  AFAIU, it exactly defines _Noreturn to use
> __attribute__ ((__noreturn__)), but I'm probably missing something.

Without the patch, the case with the comment /* _Noreturn works as-is.
*/ is used.  That causes the warnings.

> is the problem that you use clang, and config.in currently doesn't
> cater to that?

No. I don't use clang.

> If so, the change should be in config.in, I think.

I don't think so, because config.in is generated by autogen.sh.

Helmut




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Thu, 26 Jun 2025 09:14:01 GMT) Full text and rfc822 format available.

Message #20 received at 78903 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Helmut Eller <eller.helmut <at> gmail.com>
Cc: 78903 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Thu, 26 Jun 2025 12:13:39 +0300
> From: Helmut Eller <eller.helmut <at> gmail.com>
> Cc: eggert <at> cs.ucla.edu,  78903 <at> debbugs.gnu.org
> Date: Thu, 26 Jun 2025 10:40:47 +0200
> 
> On Thu, Jun 26 2025, Eli Zaretskii wrote:
> 
> >> From: Helmut Eller <eller.helmut <at> gmail.com>
> >> Cc: Paul Eggert <eggert <at> cs.ucla.edu>,  78903 <at> debbugs.gnu.org
> >> Date: Thu, 26 Jun 2025 10:08:54 +0200
> >> 
> >> On Thu, Jun 26 2025, Eli Zaretskii wrote:
> >> 
> >> >> From: Helmut Eller <eller.helmut <at> gmail.com>
> >> >> Date: Thu, 26 Jun 2025 09:20:51 +0200
> >> >> 
> >> >> When I use gcc 14 with -std=gnu99 -Wpedantic I get lots of warnings of
> >> >> the form
> >> >> 
> >> >>  warning: ISO C99 does not support ‘_Noreturn’ [-Wpedantic].
> >> >
> >> > Why did you use -Wpedantic?
> >> 
> >> To get warnings when I use a non-C99 feature.  Emacs' C code should be
> >> written in C99.  It would be easier to follow that rule it were checked
> >> automatically.
> >
> > AFAIK, Emacs is written in C99 with extensions.
> 
> It would still be easier if the somewhat arbitrary set of extensions
> would be checked automatically.
> 
> > Can you tell why the definition of _Noreturn in src/config.in doesn't
> > work for you?  AFAIU, it exactly defines _Noreturn to use
> > __attribute__ ((__noreturn__)), but I'm probably missing something.
> 
> Without the patch, the case with the comment /* _Noreturn works as-is.
> */ is used.  That causes the warnings.
> 
> > is the problem that you use clang, and config.in currently doesn't
> > cater to that?
> 
> No. I don't use clang.
> 
> > If so, the change should be in config.in, I think.
> 
> I don't think so, because config.in is generated by autogen.sh.

OK, let's see what Paul thinks about this.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Thu, 26 Jun 2025 18:44:02 GMT) Full text and rfc822 format available.

Message #23 received at 78903 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Helmut Eller <eller.helmut <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 78903 <at> debbugs.gnu.org
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Thu, 26 Jun 2025 11:43:24 -0700
On 2025-06-26 01:08, Helmut Eller wrote:
> On Thu, Jun 26 2025, Eli Zaretskii wrote:
> 
>>> From: Helmut Eller<eller.helmut <at> gmail.com>
>>> Date: Thu, 26 Jun 2025 09:20:51 +0200
>>>
>>> When I use gcc 14 with -std=gnu99 -Wpedantic I get lots of warnings of
>>> the form
>>>
>>>   warning: ISO C99 does not support ‘_Noreturn’ [-Wpedantic].
>> Why did you use -Wpedantic?
> To get warnings when I use a non-C99 feature.

To do that, you can run something like this:

  ./configure CFLAGS='-std=c99 -Wpedantic'
  make

You'll still see many warnings, though none about _Noreturn.

'-std=gnu99' says "it's OK to use GNU extensions" and so is not the best 
choice to test for C99 conformance. '-std=c99' is better (though still 
not perfect of course). Running 'configure' as shown above should avoid 
the _Noreturn warnings you mentioned.

Alternatively, you can compile with -D_Noreturn='__attribute__ 
((__noreturn__))'.

Not sure it's worth changing Gnulib to support what appears to be a GCC 
option clash. I suppose I could ask on bug-gnulib.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Thu, 26 Jun 2025 21:07:02 GMT) Full text and rfc822 format available.

Message #26 received at 78903 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Helmut Eller <eller.helmut <at> gmail.com>
Cc: 78903 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Thu, 26 Jun 2025 14:06:33 -0700
[Message part 1 (text/plain, inline)]
After looking at the definition of _Noreturn, perhaps you're right and 
it would be a win to simplify m4/gnulib-common.m4, which should pacify 
the unusual GCC configuration you mentioned. Does the attached patch 
work for you?
[noreturn.diff (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Fri, 27 Jun 2025 14:06:02 GMT) Full text and rfc822 format available.

Message #29 received at 78903 <at> debbugs.gnu.org (full text, mbox):

From: Helmut Eller <eller.helmut <at> gmail.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 78903 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Fri, 27 Jun 2025 16:05:35 +0200
On Thu, Jun 26 2025, Paul Eggert wrote:

> After looking at the definition of _Noreturn, perhaps you're right and
> it would be a win to simplify m4/gnulib-common.m4, which should pacify
> the unusual GCC configuration you mentioned. Does the attached patch
> work for you?

Yes, after a fashion.  The combination -Og -std=gnu99 -Wpedantic is
usable; -Og -std=cc99 -Wpedantic produces fewer warnings though.  With
-O0, both -std=gnu99 and -std=c99 produce too many warnings about
statement expressions to be of any use.

I would place the 201112 <= STDC_VERSION test first and only if it fails
fall back to __attribute__((__return__)).

Helmut




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Sat, 28 Jun 2025 07:08:02 GMT) Full text and rfc822 format available.

Message #32 received at 78903 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Helmut Eller <eller.helmut <at> gmail.com>
Cc: 78903 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Sat, 28 Jun 2025 00:07:02 -0700
[Message part 1 (text/plain, inline)]
On 2025-06-27 07:05, Helmut Eller wrote:
> The combination -Og -std=gnu99 -Wpedantic is
> usable; -Og -std=cc99 -Wpedantic produces fewer warnings though.  With
> -O0, both -std=gnu99 and -std=c99 produce too many warnings about
> statement expressions to be of any use.

You can suppress those statement-expression warnings by configuring this 
way:

  ./configure \
    CFLAGS='-O0 -std=c99 -Wpedantic' \
    emacs_cv_statement_expressions=no

I did that, and the resulting build generated several warnings about 
converting between function and data pointers that don't matter on any 
practical platform that I know of. I'm not sure it's worth the hassle to 
pacify GCC about them.

I did find a few other C99 violations, though, and fixed them by 
installing the attached patch.

Is it still important that Emacs port to C99? Perhaps we should upgrade 
the build requirement to C11 or later. It has been 14 years since C11, 
after all....


> I would place the 201112 <= STDC_VERSION test first and only if it fails
> fall back to __attribute__((__return__)).

Thanks for checking. I made the changes you suggested to Gnulib, and 
updated Emacs master from Gnulib. Please give it a try.
[0001-Port-varargs-macros-better-to-C99.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78903; Package emacs. (Sat, 28 Jun 2025 19:58:03 GMT) Full text and rfc822 format available.

Message #35 received at 78903 <at> debbugs.gnu.org (full text, mbox):

From: Helmut Eller <eller.helmut <at> gmail.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 78903 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Sat, 28 Jun 2025 21:57:39 +0200
On Sat, Jun 28 2025, Paul Eggert wrote:

> On 2025-06-27 07:05, Helmut Eller wrote:
>> The combination -Og -std=gnu99 -Wpedantic is
>> usable; -Og -std=cc99 -Wpedantic produces fewer warnings though.  With
>> -O0, both -std=gnu99 and -std=c99 produce too many warnings about
>> statement expressions to be of any use.
>
> You can suppress those statement-expression warnings by configuring
> this way:
>
>   ./configure \
>     CFLAGS='-O0 -std=c99 -Wpedantic' \
>     emacs_cv_statement_expressions=no

That's useful.  I didn't know about this.  Thanks.

> I did that, and the resulting build generated several warnings about
> converting between function and data pointers that don't matter on any
> practical platform that I know of. I'm not sure it's worth the hassle
> to pacify GCC about them.

Probably not; there aren't that many.  It's an odd warning that deserves
the name "pedantic."

> I did find a few other C99 violations, though, and fixed them by
> installing the attached patch.

Thanks.

> Is it still important that Emacs port to C99? Perhaps we should
> upgrade the build requirement to C11 or later. It has been 14 years
> since C11, after all....

Not my decision to make.  Some lightweight compilers like Tiny CC or PCC
apparently only support C99.  Not sure how relevant those are, though.

>> I would place the 201112 <= STDC_VERSION test first and only if it fails
>> fall back to __attribute__((__return__)).
>
> Thanks for checking. I made the changes you suggested to Gnulib, and
> updated Emacs master from Gnulib. Please give it a try.

Oh. That must have been a lot of work.  Thanks again.

Helmut




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Sun, 29 Jun 2025 00:17:03 GMT) Full text and rfc822 format available.

Notification sent to Helmut Eller <eller.helmut <at> gmail.com>:
bug acknowledged by developer. (Sun, 29 Jun 2025 00:17:03 GMT) Full text and rfc822 format available.

Message #40 received at 78903-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Helmut Eller <eller.helmut <at> gmail.com>
Cc: 78903-done <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#78903: [PATCH] ISO C99 does not support _Noreturn
Date: Sat, 28 Jun 2025 17:16:06 -0700
On 2025-06-28 12:57, Helmut Eller wrote:

> That must have been a lot of work.  Thanks again.

You're welcome. It's not that much work, as I can run 
'admin/merge-gnulib' in the Emacs source directory to do most of Gnulib 
importation automatically. Closing the bug report.




This bug report was last modified 20 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.