From: Gabriel Ravier <gabravier@gmail.com>
To: "Po Lu" <luangruo@yahoo.com>, "Arsen Arsenović" <arsen@aarsen.me>
Cc: Eli Zaretskii <eliz@gnu.org>, jwakely.gcc@gmail.com, gcc@gcc.gnu.org
Subject: Re: More C type errors by default for GCC 14
Date: Fri, 12 May 2023 14:30:24 +0200 [thread overview]
Message-ID: <840bb51c-3aab-30c3-8330-40201c2b6bab@gmail.com> (raw)
In-Reply-To: <87ilcyb7il.fsf@yahoo.com>
On 5/12/23 04:36, Po Lu via Gcc wrote:
> Arsen Arsenović <arsen@aarsen.me> writes:
>
>> Indeed they should be - but warning vs. error holds significance. A
>> beginner is much less likely to be writing clever code that allegedly
>> uses these features properly than to be building new code, and simply
>> having made an error that they do not want and will suffer through
>> confused.
> Most programs already paste a chunk of Autoconf into their configure.ins
> which turns on more diagnostics if it looks like the program is being
> built by a developer. i.e. from Emacs:
>
> AC_ARG_ENABLE([gcc-warnings],
> [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
> [control generation of GCC warnings. The TYPE 'yes'
> means to fail if any warnings are issued; 'warn-only'
> means issue warnings without failing (default for
> developer builds); 'no' means disable warnings
> (default for non-developer builds).])],
> [case $enableval in
> yes|no|warn-only) ;;
> *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
> esac
> gl_gcc_warnings=$enableval],
> [# By default, use 'warn-only' if it looks like the invoker of 'configure'
> # is a developer as opposed to a builder. This is most likely true
> # if GCC is recent enough and there is a .git directory or file;
> # however, if there is also a .tarball-version file it is probably
> # just a release imported into Git for patch management.
> gl_gcc_warnings=no
> if test -d "$srcdir"/.git && test ! -f "$srcdir"/.tarball-version; then
> # Clang typically identifies itself as GCC 4.2 or something similar
> # even if it is recent enough to accept the warnings we enable.
> AS_IF([test "$emacs_cv_clang" = yes],
> [gl_gcc_warnings=warn-only],
> [gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only])])
> fi])
>
> So this is really not a problem.
>
>> Indeed. I said facilitates, not treats equally. I think the veterans
>> here won't lose much by having to pass -fpermissive, and I think that's
>> a worthwhile sacrifice to make, to nurture the new without pressuring
>> the old very much.
> Until `-fpermissive' goes the way of `-traditional',
> `-fwritable-strings'.
>
>> On that note - lets presume a beginners role. I've just started using
>> GCC. I run 'gcc -O2 -Wall main.c fun.c' and I get an a.out. It
>> mentions some 'implicit function generation', dunno what that means - if
>> it mattered much, it'd have been an error. I wrote a function called
>> test that prints the int it got in hex, but I called it with 12.3, but
>> it printed 1.. what the heck?
> Have you actually seen anyone make this mistake?
As somebody that spends a lot of time helping beginners, yes,
constantly. I'd go as far as to say it's an error that seemingly
everyone has made at least once.
>
>> Why that happened is obvious to you and I (if you're on the same CPU as
>> me), but to a beginner is utter nonsense.
>>
>> At this point, I can only assume one goes to revisit that warning.. I'd
>> hope so at least.
>>
>> I doubt the beginner would know to pass
>> -Werror=implicit-function-declaration in this case (or even about
>> Werror... I just told them what -Wall and to read the warnings, which
>> was gleefully ignored)
> I'd expect a question from the newbie, directed at a web search engine.
>
>> Hell, I've seen professors do it, and for a simple reason: they knew how
>> to write code, not how to use a compiler. That's a big gap.
>>
>> The beginner here can't adapt - they don't know what -Wall means, they
>> just pass it because they were told to do it (if they're lucky!).
> If this is really such a bad problem, then how about clarifying the
> error message?
>
>> At the same time, they lose out on what is, IMO, one of the most useful
>> pieces of the toolchain: _FORTIFY_SOURCE (assuming your vendor enables
>> it by default.. we do). It provides effective bug detection, when the
>> code compiles right. It regularly spots bugs that haven't happened yet
>> for me.
>>
>> (and same goes for all the other useful analysis the toolchain can do
>> when it has sufficient information to generate correct code, or more;
>> some of which can't reasonably be a default)
>>
>> (on a related note, IMO it's a shame that the toolchain hides so many
>> possibilities behind 'cult knowledge', depths of many manuals and bad
>> defaults)
> _FORTIFY_SOURCE is not really important enough to be considered here.
> It's not even available everywhere.
>
>> This sample is subject to selection bias. My testing targets mostly
>> more modern codebases that have long fixed these errors (if they have
>> active maintainers), and exclusively Free Software, so I expect that the
>> likelyhood that you'll need to run `export CC='gcc -fpermissive'
>> CXX='g++ -fpermissive'` goes up the more you move towards old or more
>> corporate codebases, but, for a veteran, this is no cost at all.
>>
>> Is it that much of a stretch to imagine that a maintainer of a codebase
>> that has not seen revisions to get it past K&R-esque practices would
>> know that they need to pass -std=c89 (or a variant of such), or even
>> -fpermissive - assuming that they could even spare to use GCC 14 as
>> opposed to 2.95?
> There's bash, which still tries to work on later 4.3BSDs (AFAIK), while
> also building with just `gcc'.
>
>> As an anecdote, just recently I had to fix some code written for i686
>> CPUs, presumably for GCC 4.something or less, because the GCC I insist
>> on using (which is 13 and has been since 13.0 went into feature-freeze)
>> has started using more than the GPRs on that machine (which lead to hard
>> to debug crashes because said codebase does not enable the requisite CPU
>> extensions, or handle the requisite registers properly). I think this
>> fits within the definition of 'worked yesterday, broke today'. Should
>> that change be reverted? Replacing it with -mmore-than-gprs would make
>> GCC more compatible with this old code.
>>
>> I don't think so.
>>
>> This is a sensitive codebase, and not just because it's written poorly,
>> but because it's a touchy thing it's implementing, any change in
>> compiler requires reverification. The manifestation here has *no*
>> significance.
> And the problematic part of the code in question is implementing
> something like swapcontext in assembler, correct? That's a far cry from
> breaking C code, which does have clearly defined (albeit not exactly
> intuitive) semantics.
>
>> ... speaking of that, if one builds their codebase without -std=..,
>> they're risking more than just optimization changes breaking code that
>> relies on bad assumptions, they're also risking a change in language
>> semantics..
> The Standards committee does have a reasonable track record of keeping
> backwards compatibility, since they prioritize existing practice and the
> existing body of C code. So I'm not too worried about that.
>
>> With all that to consider, is it *really* a significant cost to add
>> -fpermissive?
> Yes, in case it goes away.
>
>> Would that cost not be massively overshadowed by the cost
>> of a compiler change? It feels like it's a footnote compared to
>> checking whether added optimizations go against invalid assumptions
>> (which is, by the way, also rectified by adding more hard and easy
>> to see errors).
>>
>> I expect no change in behavior from those that maintain these old
>> codebases, they know what they're doing, and they have bigger fish to
>> fry - however, I expect that this change will result in:
>>
>> - A better reputation for GCC and the GCC project (by showing that we do
>> care for code correctness),
> A compiler should care about the correctness of its own code, not that
> of others.
>
>> - More new code being less error prone (by merit of simple errors being
>> detected more often),
> As I said, making such things errors will simply result in people
> inserting `extern' declarations everywhere, which may or may not be
> wrong. I've seen this happen before with my own eyes.
>
>> - Less 'cult knowledge' in the garden path,
> I guess search engines, and better written diagnostic messages, would be
> enough to accomplish that?
>
>> - More responsible beginners, and
>> - Fewer people being able to effectively paint GNU and/or C/++ as the
>> backwards crowd using a error-prone technique of yesteryear.
> This never worked in GNU C++, right?
>
>> (and yes, optics matter)
>>
>> Builds break. Builds breaking cleanly is a treat compared to the usual
>> breakage. At least this breaks the few that do break with a positive
>> outcome.
> Builds shouldn't break, and the ``usual treat'' should also not
> happen...
next prev parent reply other threads:[~2023-05-12 12:30 UTC|newest]
Thread overview: 246+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 12:15 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=840bb51c-3aab-30c3-8330-40201c2b6bab@gmail.com \
--to=gabravier@gmail.com \
--cc=arsen@aarsen.me \
--cc=eliz@gnu.org \
--cc=gcc@gcc.gnu.org \
--cc=jwakely.gcc@gmail.com \
--cc=luangruo@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).