public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* More C type errors by default for GCC 14
@ 2023-05-09 12:15 Florian Weimer
  2023-05-09 14:16 ` Dave Blanchard
                   ` (4 more replies)
  0 siblings, 5 replies; 246+ messages in thread
From: Florian Weimer @ 2023-05-09 12:15 UTC (permalink / raw)
  To: gcc; +Cc: c-std-porting

TL;DR: This message is about turning implicit-int,
implicit-function-declaration, and possibly int-conversion into errors
for GCC 14.

A few of you might remember that I've been looking into turning some
type errors from warnings into errors by default.  Mainly I've been
looking at implicit function declarations because in too many cases, the
synthesized declaration does not match the prototype used at function
definition and can cause subtle ABI issues.

To recap, the main challenge is that GCC has to serve disparate groups
of users: some use GCC for writing programs themselves, but others just
need GCC to build sources that they have obtained from somewhere.  The
first group benefits from more type errors because they catch errors
earlier during development (experience shows that compiler warnings are
easy to miss in a long build log).  The second group might find these
errors challenging because the sources they have no longer build.

To see how large the impact is on that second group, we've mostly
removed implicit function declarations and implicit ints from Fedora:

  <https://fedoraproject.org/wiki/Changes/PortingToModernC>
  <https://fedoraproject.org/wiki/Toolchain/PortingToModernC>

Roughly 870 packages out of ~14,500 that have GCC present during the
build needed fixing (or flagging that they can't be built with the
additional errors), so 6%.  Most of the changes are mechanical in
nature, like adding additional headers to configure checks.  For about
~150 packages, automated patching could be used to rewrite problematic
built-in checks generated by long-obsolete autoconf versions.

Some of these changes prevent the compiler behavior for altering the
build results silently because the new errors changed the outcome of
autoconf checks.  (We had one of those in libstdc++, changing the ABI on
GNU/Linux because futex support oculd no longer be detected.)
Unfortunately, I did not record numbers about them, but think those were
quite rare; most autoconf problems were also accompanied with other
problems, or the incorrect results from autoconf led to build failures
later.  So it seems to me that the risk that the second group mentioned
above would silently get unexpected build results is fairly low.

Where possible, we tried to upstream patches, to simplify sharing across
distributions and to help those who compile upstream sources directly.
We also benefited from other distributions upstreaming changes along
similar lines (notably Gentoo for their Clang 16 project, but also from
Homebrew to a lesser extent).

An area we started exploring only recently for Fedora is implicit
conversions between integers and pointers (covered by -Wint-conversion).
These add another ~170 packages, but some of those are false positives
(due to our instrumented compiler approach) that do not change the build
outcome at all.  I'm still negotiating whether we have the capacity to
develop fixes for these packages proactively.

I brought up the matter with distributions, and the feedback was neutral
(not overly negative, as in “this would be the end of the world for
us”).

  <https://discourse.nixos.org/t/rfc-more-c-errors-by-default-in-gcc-14/27390>
  <https://lists.debian.org/debian-gcc/2023/04/msg00015.html>
  <https://lists.opensuse.org/archives/list/factory@lists.opensuse.org/thread/5OL76NH5AX75WOTZ43O3ZF2JOS3ABBXL/#QZLCA5YPN5CWSS7BCC6TNBC6N7RFTW7J>

(I tried to contact Arch, but my message didn't make it past the
moderators, it seems.)

All in all, the whole situation is not great, but it still seems
manageable to me.

Anyway, thanks for reading this far.

I would like to suggest to turn implicit-int,
implicit-function-declaration, and possibly int-conversion from warnings
into errors for GCC 14.  This would give upstream projects roughly
another year to make new releases with compatibility fixes that have
been contributed so far.  I do not think waiting longer, until GCC 15,
would make a meaningful difference because any upstream project that
does not release within the next 12 months is not likely to release in
the next 24 months, either.

Regarding mechanics of the necessary opt out facility, Clang used
-Werror=… by default, but that seems a bit hackish to me.  Presently, we
cannot use -std=gnu89 etc. to opt out because there are packages which
require both C89-only language features and C99-style inlining, which is
currently not a combination supported by GCC (but maybe that could be
changed).  Some build systems do not treat CFLAGS and CXXFLAGS as fully
separate, and a flag approach that works for C and C++ without
introducing any new warnings would be most convenient.  So maybe we
could use -fpermissive for C as well.

One fairly big GCC-internal task is to clear up the C test suite so that
it passes with the new compiler defaults.  I already have an offer of
help for that, so I think we can complete this work in a reasonable time
frame.

I have no data how big the compatibility impact of turning
incompatible-pointer-types into errors will be.  For now, int-conversion
has higher priority.  However, it looks like another change that could
benefit developers (the first group).

I do not plan to work specifically on C2X compatibility fixes for now
(to support bool-as-keyword, for example), but I could imagine a similar
project a few years from now, fewer than 25 hopefully, that would enable
GCC to make the switch to C2X by default.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 246+ messages in thread
* More C type errors by default for GCC 14
@ 2023-05-10 12:41 Marcin Jaczewski
  2023-05-10 14:19 ` Eli Zaretskii
  0 siblings, 1 reply; 246+ messages in thread
From: Marcin Jaczewski @ 2023-05-10 12:41 UTC (permalink / raw)
  To: Eli Zaretskii, gcc

I think the biggest problem you have is that you try to upgrade the compiler
to compile code that nobody has touched in 30years.

Adding `-fpermissive` is the least concern you should have.

Did you even check if the compiler outpost is still correct?
As you are really on some obsolete functionality it could easily rot
and the new compiler can not handle it correctly.

You mention "validations and verifications", do you do the same
with the new compiler?

If you can't touch code then you SHOULD not upgrade the compiler.
If you upgrade the compiler you SHOULD upgrade code.

Any big project (like Linux) shows these two rules are critical,
there were multiple cases of security bugs caused by subtle change
in behavior of the compiler.
Compiling very old code is lability if nobody knows how it should work and
nobody maintains it. Who can give you guarantee that the result is correct?
Very old programs should even by default reject new compilers by default until
someone does not check if it correctly compiles on new compilers.

^ permalink raw reply	[flat|nested] 246+ messages in thread
* Re: More C type errors by default for GCC 14
@ 2023-05-10 13:10 Basile Starynkevitch
  2023-05-10 14:20 ` David Brown
  0 siblings, 1 reply; 246+ messages in thread
From: Basile Starynkevitch @ 2023-05-10 13:10 UTC (permalink / raw)
  To: gcc, Eric Gallager, Eli Zaretskii

Hello all,

After a suggestion by Eric Gallager
> Idea for a compromise: What if, instead of flipping the switch on all
> 3 of these at once, we staggered them so that each one becomes a
> default in a separate release? i.e., something like:
>
> - GCC 14: -Werror=implicit-function-declaration gets added to the defaults
> - GCC 15: -Werror=implicit-int gets added to the defaults
> - GCC 16: -Werror=int-conversion gets added to the defaults
>
> That would give people more time to catch up on a particular warning,
> rather than overwhelming them with a whole bunch all at once. Just an
> idea.

Eli Zaretskii <eliz@gnu.org> wrote on 10 may 2023, at 14:00

> And that is just one example of perfectly valid reasons for not
> wanting or not being able to make changes to pacify GCC.
>
> Once again, my bother is not about "villains" who don't want to get
> their act together, my bother is about cases such as the one above,
> where the developers simply have no practical choice.
>
> And please don't tell me they should use an older GCC, because as
> systems go forward and are upgraded, older GCC will not work anymore.


My experience is that for safety critical software (per DOI 178C, 
embedded in aircrafts, or for the French covid breathing machine on 
https://github.com/Recovid/Controller ) the regulations, funders, and 
authorities requires a very specific version of GCC with very specific 
compilation flags.


Changing either the compiler (even from gcc-12.1 to gcc-12.2) or the 
compilation flags (even changing -O1 by -O2) requires written (on paper) 
approval by a large number of human persons, and formal certifications 
(eg ISO9001, ISO27001 procedures) and lots of checks and headaches.


I do know several persons making their living of these constraints.

I do know several corporations making a living from them (and keeping 
decade older GCC compiler binaries on many disks).

So I really think that for safety critical software (whose failure may 
impact lives) people are using an older (and well specified) GCC.


Of course, to compile an ordinary business web service (e-shop for 
clothes) with e.g. libonion (from https://github.com/davidmoreno/onion 
...) or to compile a zsh.org from source code (for or on a developer's 
laptop) the constraints are a lot lighter.

Regards!


PS : my pet open source project is the RefPerSys open source inference 
engine on http://refpersys.org/ and 
https://github.com/RefPerSys/RefPerSys ; it is explicitly thought for 
non-critical use (desktop, teaching, ...).

-- 
Basile Starynkevitch                  <basile@starynkevitch.net>
(only mine opinions / les opinions sont miennes uniquement)
92340 Bourg-la-Reine, France
web page: starynkevitch.net/Basile/


^ permalink raw reply	[flat|nested] 246+ messages in thread

end of thread, other threads:[~2023-05-17 10:06 UTC | newest]

Thread overview: 246+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-09 12:15 More C type errors by default for GCC 14 Florian Weimer
2023-05-09 14:16 ` Dave Blanchard
2023-05-09 15:03 ` David Edelsohn
2023-05-09 15:07   ` Sam James
2023-05-09 15:35     ` Dave Blanchard
2023-05-09 15:58       ` Jonathan Wakely
2023-05-09 16:26       ` Arsen Arsenović
2023-05-09 15:14   ` Jonathan Wakely
2023-05-09 15:22     ` Dave Blanchard
2023-05-09 16:38       ` Arsen Arsenović
2023-05-09 16:57         ` Eli Zaretskii
2023-05-09 17:05           ` Sam James
2023-05-09 18:55             ` Eli Zaretskii
2023-05-09 17:15           ` Jonathan Wakely
2023-05-09 19:04             ` Eli Zaretskii
2023-05-09 19:07               ` Jakub Jelinek
2023-05-09 19:22                 ` Eli Zaretskii
2023-05-09 20:13                   ` David Edelsohn
2023-05-09 20:21                     ` Arsen Arsenović
2023-05-10  2:38                       ` Eli Zaretskii
2023-05-10  8:36                         ` Arsen Arsenović
2023-05-10 11:52                           ` Eli Zaretskii
2023-05-10 11:56                             ` Jonathan Wakely
2023-05-10 12:25                               ` Eli Zaretskii
2023-05-10 12:30                                 ` Jonathan Wakely
2023-05-10 12:44                                   ` Eli Zaretskii
2023-05-15 12:28                         ` Richard Earnshaw (lists)
2023-05-15 20:17                           ` Eric Gallager
2023-05-16  7:05                             ` Florian Weimer
2023-05-16 15:56                               ` Jason Merrill
2023-05-09 20:40                     ` Jonathan Wakely
2023-05-09 22:27                       ` David Edelsohn
2023-05-09 22:37                         ` Joel Sherrill
2023-05-09 22:45                           ` Jonathan Wakely
2023-05-10 10:40                             ` Eric Gallager
2023-05-10 10:45                               ` Sam James
2023-05-10 10:56                                 ` Neal Gompa
2023-05-10 12:06                                   ` Eli Zaretskii
2023-05-10 12:10                                     ` Neal Gompa
2023-05-10 12:41                                       ` Eli Zaretskii
2023-05-10 10:48                               ` Jonathan Wakely
2023-05-10 10:51                                 ` Jonathan Wakely
2023-05-10 12:00                               ` Eli Zaretskii
2023-05-10 12:42                                 ` Sam James
2023-05-10 15:10                             ` Joel Sherrill
2023-05-10 15:14                               ` Jakub Jelinek
2023-05-10 16:36                                 ` Joel Sherrill
2023-05-10 16:44                                   ` Jakub Jelinek
2023-05-10 17:05                                   ` Jonathan Wakely
2023-05-10 18:37                             ` James K. Lowden
2023-05-10 23:26                               ` Jonathan Wakely
2023-05-11 18:47                                 ` Jason Merrill
2023-05-10 23:33                               ` Sam James
2023-05-11  5:48                               ` Eli Zaretskii
2023-05-11  2:28                             ` Po Lu
2023-05-11  2:09                       ` Po Lu
2023-05-11  2:14                         ` Sam James
2023-05-11  2:23                           ` Po Lu
2023-05-11  3:14                             ` Eli Schwartz
2023-05-11  3:56                               ` Po Lu
2023-05-11  4:46                                 ` Eli Schwartz
2023-05-11  4:49                                   ` Eli Schwartz
2023-05-11  6:23                                     ` Po Lu
2023-05-11  6:18                                   ` Po Lu
2023-05-11 22:41                                     ` Eli Schwartz
2023-05-12  2:08                                       ` Po Lu
2023-05-12  3:07                                         ` Eli Schwartz
2023-05-12  5:57                                           ` Po Lu
2023-05-12 11:05                                             ` Gabriel Ravier
2023-05-12 13:53                                               ` Po Lu
2023-05-12 14:03                                                 ` Jonathan Wakely
2023-05-14 12:35                                                 ` Mark Wielaard
2023-05-12 11:48                                             ` Is the GNUC dialect anything that GCC does when given source code containing UB? (Was: More C type errors by default for GCC 14) Eli Schwartz
2023-05-12 13:07                                               ` Is the GNUC dialect anything that GCC does when given source code containing UB? Po Lu
2023-05-12  6:56                                           ` More C type errors by default for GCC 14 Eli Zaretskii
2023-05-12  7:28                                             ` Jonathan Wakely
2023-05-12 10:36                                               ` Eli Zaretskii
2023-05-12 13:19                                               ` Po Lu
2023-05-12 13:25                                                 ` Gabriel Ravier
2023-05-13  0:45                                                   ` Po Lu
2023-05-13  5:30                                                     ` Thomas Koenig
2023-05-13  5:53                                                       ` Po Lu
2023-05-14  5:10                                                         ` Eli Schwartz
2023-05-14  5:38                                                           ` Po Lu
2023-05-14  9:46                                                             ` David Brown
2023-05-14 10:21                                                               ` Jonathan Wakely
2023-05-14 10:23                                                                 ` Jonathan Wakely
2023-05-14  5:08                                                     ` Eli Schwartz
2023-05-14  5:28                                                       ` Po Lu
2023-05-14  5:56                                                         ` Eli Schwartz
2023-05-14 11:55                                                           ` Po Lu
2023-05-14 12:22                                                             ` Arsen Arsenović
2023-05-15  1:05                                                               ` Po Lu
2023-05-14  6:03                                                         ` Eli Schwartz
2023-05-14  8:47                                                         ` Jonathan Wakely
2023-05-14 12:05                                                           ` Po Lu
2023-05-14 12:48                                                             ` Nicholas Vinson
2023-05-14 10:29                                                         ` David Brown
2023-05-12 15:51                                                 ` Jason Merrill
2023-05-17 10:06                                                   ` Florian Weimer
2023-05-12 11:26                                         ` David Brown
2023-05-11  6:24                                   ` Eli Zaretskii
2023-05-11 22:43                                     ` Eli Schwartz
2023-05-12  2:38                                       ` Po Lu
2023-05-12  2:55                                         ` Jason Merrill
2023-05-12  6:01                                           ` Po Lu
2023-05-12  6:40                                             ` Jonathan Wakely
2023-05-12 13:23                                               ` Po Lu
2023-05-12 10:49                                             ` Pedro Alves
2023-05-12 13:26                                               ` Po Lu
2023-05-12 11:55                                             ` Eli Schwartz
2023-05-12 13:54                                               ` Po Lu
2023-05-12  6:49                                           ` Eli Zaretskii
2023-05-12  2:56                                         ` Sam James
2023-05-12  6:03                                           ` Po Lu
2023-05-12  3:06                                         ` Sam James
2023-05-12  6:25                                       ` Eli Zaretskii
2023-05-12 11:23                                         ` Gabriel Ravier
2023-05-11  6:12                               ` Eli Zaretskii
2023-05-11  7:04                                 ` Jonathan Wakely
2023-05-11 22:30                                 ` Eli Schwartz
2023-05-11 22:35                                   ` Sam James
2023-05-12  2:40                                     ` Po Lu
2023-05-12  2:52                                       ` Sam James
2023-05-12  5:32                                         ` Po Lu
2023-05-12  2:39                                   ` Po Lu
2023-05-12  3:18                                     ` Eli Schwartz
2023-05-12  6:17                                   ` Eli Zaretskii
2023-05-11  7:59                         ` David Brown
2023-05-09 21:00                     ` Thomas Koenig
2023-05-09 21:17                       ` Arsen Arsenović
2023-05-10 13:57                       ` Florian Weimer
2023-05-10 11:00                     ` David Brown
2023-05-11 10:49                       ` James K. Lowden
2023-05-11  1:38                     ` Po Lu
2023-05-11  1:43                       ` Sam James
2023-05-11  2:20                         ` Po Lu
2023-05-09 20:57                   ` Florian Weimer
2023-05-10  2:33                     ` Eli Zaretskii
2023-05-10  8:04                       ` Jonathan Wakely
2023-05-10  8:46                         ` Richard Biener
2023-05-10 12:26                           ` Florian Weimer
2023-05-10 11:30                         ` Eli Zaretskii
2023-05-10 12:03                           ` Jakub Jelinek
2023-05-10 12:36                             ` Eli Zaretskii
2023-05-10 12:41                               ` Gabriel Ravier
2023-05-10 14:14                                 ` Eli Zaretskii
2023-05-10 14:22                                   ` Jakub Jelinek
2023-05-10 15:30                                     ` Eli Zaretskii
2023-05-10 16:02                                       ` Jakub Jelinek
2023-05-10 16:31                                         ` Eli Zaretskii
2023-05-10 16:33                                           ` Richard Biener
2023-05-10 16:57                                             ` Eli Zaretskii
2023-05-10 17:08                                           ` Joseph Myers
2023-05-10 18:18                                             ` Eli Zaretskii
2023-05-12 15:02                                             ` Florian Weimer
2023-05-12 17:52                                               ` Florian Weimer
2023-05-12 17:55                                                 ` Gabriel Ravier
2023-05-12 18:00                                                   ` Florian Weimer
2023-05-12 18:08                                                   ` Alexander Monakov
2023-05-12 18:14                                                     ` Florian Weimer
2023-05-15 12:51                                                       ` Michael Matz
2023-05-16  8:55                                                         ` Florian Weimer
2023-05-16 10:39                                                           ` Alexander Monakov
2023-05-16 11:01                                                             ` Jakub Jelinek
2023-05-16 11:09                                                               ` Jonathan Wakely
2023-05-16 11:15                                                               ` Florian Weimer
2023-05-12 19:44                                               ` Joseph Myers
2023-05-12 20:43                                                 ` Florian Weimer
2023-05-12 20:18                                               ` Jason Merrill
2023-05-12 20:57                                                 ` Florian Weimer
2023-05-12 21:20                                                   ` Sam James
2023-05-12 21:21                                               ` Sam James
2023-05-12 21:37                                                 ` Florian Weimer
2023-05-12 21:47                                                   ` Sam James
2023-05-12 21:59                                                     ` Florian Weimer
2023-05-10 15:58                                   ` David Brown
2023-05-10 16:28                                     ` Eli Zaretskii
2023-05-11  6:52                                       ` David Brown
2023-05-11  7:39                                         ` Eli Zaretskii
2023-05-10 14:31                             ` Thomas Koenig
2023-05-10 15:37                               ` Eli Zaretskii
2023-05-11  2:38                         ` Po Lu
2023-05-11  7:38                           ` Arsen Arsenović
2023-05-11  8:31                             ` Po Lu
2023-05-11  8:44                               ` Arsen Arsenović
2023-05-11  9:28                                 ` Po Lu
2023-05-11 21:10                                   ` Arsen Arsenović
2023-05-12  1:41                                     ` Po Lu
2023-05-11 10:35                                 ` Eli Zaretskii
2023-05-11 19:25                                   ` Arsen Arsenović
2023-05-12  2:36                                     ` Po Lu
2023-05-12 12:30                                       ` Gabriel Ravier
2023-05-12 13:56                                         ` Po Lu
2023-05-12  7:53                                     ` Eli Zaretskii
2023-05-12  8:15                                       ` Jakub Jelinek
2023-05-12 10:40                                         ` Eli Zaretskii
2023-05-12  8:45                                       ` Christian Groessler
2023-05-12 10:14                                         ` Jonathan Wakely
2023-05-12  9:11                                       ` Thomas Koenig
2023-05-11  8:53                               ` Jonathan Wakely
2023-05-11  9:29                                 ` Po Lu
2023-05-10  8:49               ` David Brown
2023-05-10 11:37                 ` Eli Zaretskii
2023-05-10 11:49                   ` Jonathan Wakely
2023-05-10 12:22                     ` Eli Zaretskii
2023-05-10 13:30                       ` David Brown
2023-05-10 14:39                         ` Eli Zaretskii
2023-05-10 15:21                           ` Paul Koning
2023-05-10 16:20                           ` David Brown
2023-05-10 16:48                             ` Eli Zaretskii
2023-05-10 12:32                   ` Sam James
2023-05-10 12:47                     ` Eli Zaretskii
2023-05-09 19:33           ` Arsen Arsenović
2023-05-09 15:25     ` David Edelsohn
2023-05-11  1:25     ` Po Lu
2023-05-11  1:30       ` Sam James
2023-05-11  1:33       ` Sam James
2023-05-11  2:18         ` Po Lu
2023-05-11  6:44           ` Jonathan Wakely
2023-05-11  8:32             ` Po Lu
2023-05-11  8:52               ` Jonathan Wakely
2023-05-11  7:36       ` Arsen Arsenović
2023-05-11  8:23         ` Po Lu
2023-05-09 18:22   ` Florian Weimer
2023-05-11 21:32     ` Segher Boessenkool
2023-05-09 15:16 ` Richard Biener
2023-05-09 16:05   ` Jakub Jelinek
2023-05-09 16:11     ` Sam James
2023-05-09 16:13     ` David Edelsohn
     [not found]       ` <BBE9950C-28AA-4A1C-A4C5-7F486538004E@gmail.com>
2023-05-09 16:44         ` Florian Weimer
2023-05-09 16:58           ` Ian Lance Taylor
2023-05-09 17:08           ` Jason Merrill
2023-05-09 17:16             ` Sam James
2023-05-09 16:59   ` Florian Weimer
2023-05-09 17:07     ` Sam James
2023-05-09 17:35       ` Florian Weimer
2023-05-11 15:21 ` Peter0x44
2023-05-12  9:33 ` Martin Jambor
2023-05-12 12:30   ` Jakub Jelinek
2023-05-15 12:46     ` Michael Matz
2023-05-15 13:14     ` Richard Earnshaw (lists)
2023-05-10 12:41 Marcin Jaczewski
2023-05-10 14:19 ` Eli Zaretskii
2023-05-10 13:10 Basile Starynkevitch
2023-05-10 14:20 ` David Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).