C89 question: Do we need to accept -Wint-conversion warnings
Florian Weimer
fweimer@redhat.com
Wed Oct 11 11:38:12 GMT 2023
* 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
More information about the Gcc
mailing list