public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: David Brown <david@westcontrol.com>
Cc: Jason Merrill <jason@redhat.com>,  gcc@gcc.gnu.org
Subject: Re: C89 question: Do we need to accept -Wint-conversion warnings
Date: Wed, 11 Oct 2023 13:38:12 +0200	[thread overview]
Message-ID: <878r89wfrv.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <d4f09edb-29dd-9fa3-8e64-6a86b3bb748e@westcontrol.com> (David Brown's message of "Wed, 11 Oct 2023 13:28:12 +0200")

* David Brown:

>> C23 changes meaning of of extern foo(); to match the C++
>> interpretation of extern foo(void);.  I don't think we should warn
>> about that.  If we warn, it would be at the call site.
>
> I'm not sure I fully agree.  "extern foo();" became invalid when
> implicit int was removed in C99.  But "extern T foo();", where "T" is
> void or any type, has changed meaning between C17 (and before) and
> C23.

My concern is that the warning would not really be actionable.
Encouraging programmers to change foo() to foo(void) in declarations
seems merely busywork.  C++ doesn't need this, and future C won't need
it, either.

> IMHO I think calling "foo" with parameters should definitely be a
> warning, enabled by default, for at least -std=c99 onwards - it is
> almost certainly a mistake.  (Those few people that use it as a
> feature can ignore or disable the warning.)

It's possible to disable this warning in C23 by declaring foo as ”extern
T foo(...);”.  Not sure if this has ABI implications.

> I would also put warnings on the declaration itself at -Wall, or at
> least -Wextra (i.e., "-Wstrict-prototypes").  I think that things that
> change between standards, even subtly, should be highlighted.
> Remember, this concerns a syntax that was marked obsolescent some 35
> years ago, because the alternative (prototypes) was considered
> "superior to the old style on every count".

I still think the declaration is quite harmless if we warn at call
sites.

Thanks,
Florian


  reply	other threads:[~2023-10-11 11:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10 11:29 Florian Weimer
2023-10-10 16:30 ` Jason Merrill
2023-10-10 16:38   ` Jakub Jelinek
2023-10-10 17:06     ` Florian Weimer
2023-10-10 17:38       ` Joel Sherrill
2023-10-11  7:36   ` David Brown
2023-10-11  8:10     ` Florian Weimer
2023-10-11  8:51       ` David Brown
2023-10-11 10:17         ` Florian Weimer
2023-10-11 11:28           ` David Brown
2023-10-11 11:38             ` Florian Weimer [this message]
2023-10-10 16:38 ` Joseph Myers
2023-10-10 17:07   ` Florian Weimer

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=878r89wfrv.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=david@westcontrol.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jason@redhat.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).