public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/95445] New: diagnose incompatible calls to functions declared without prototype @ 2020-05-30 22:32 msebor at gcc dot gnu.org 2020-05-30 22:32 ` [Bug c/95445] " msebor at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: msebor at gcc dot gnu.org @ 2020-05-30 22:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95445 Bug ID: 95445 Summary: diagnose incompatible calls to functions declared without prototype Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- GCC silently accepts calls to built-in functions declared without a prototype as long as the arguments match the expected types (based on the prototype hardcoded into GCC), but issues warnings for calls where the arguments don't match. But GCC makes no attempt to make sure that in calls to other (i.e., non-built-in) functions declared without prototype provided arguments have the same type across all the calls. Diagnosing mismatches as suggested in the comments below would help detect bugs caused by their incompatibily. This enhancement is different from pr92212 which is about calls to K&R functions defined in the same translation unit. $ cat x.c && gcc -O2 -S -Wall x.c char* strchr (); char* f0 (const char *s) { return strchr (s, 'x'); // no warning (okay) } char* f1 (const char *s) { return strchr (s, "y"); // warning (good) } void g (); void h (void) { g (1); // (presumably) okay, f's type is 'void (int)' g ("foo"); // should be diagnosed g (1, "bar"); // ditto } x.c: In function ‘f1’: x.c:10:21: warning: passing argument 2 of ‘strchr’ makes integer from pointer without a cast [-Wint-conversion] 10 | return strchr (s, "y"); // warning (good) | ^~~ | | | char * x.c:1:7: note: expected ‘int’ but argument is of type ‘char *’ 1 | char* strchr (); | ^~~~~~ ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/95445] diagnose incompatible calls to functions declared without prototype 2020-05-30 22:32 [Bug c/95445] New: diagnose incompatible calls to functions declared without prototype msebor at gcc dot gnu.org @ 2020-05-30 22:32 ` msebor at gcc dot gnu.org 2021-10-27 5:21 ` egallager at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: msebor at gcc dot gnu.org @ 2020-05-30 22:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95445 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |87403 Severity|normal |enhancement See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=92212 Keywords| |diagnostic Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403 [Bug 87403] [Meta-bug] Issues that suggest a new warning ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/95445] diagnose incompatible calls to functions declared without prototype 2020-05-30 22:32 [Bug c/95445] New: diagnose incompatible calls to functions declared without prototype msebor at gcc dot gnu.org 2020-05-30 22:32 ` [Bug c/95445] " msebor at gcc dot gnu.org @ 2021-10-27 5:21 ` egallager at gcc dot gnu.org 2023-05-12 15:54 ` fw at gcc dot gnu.org 2023-05-12 16:29 ` sjames at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: egallager at gcc dot gnu.org @ 2021-10-27 5:21 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95445 Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.org --- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> --- Is this like clang's -Wknr-promoted-parameter? https://clang.llvm.org/docs/DiagnosticsReference.html#wknr-promoted-parameter ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/95445] diagnose incompatible calls to functions declared without prototype 2020-05-30 22:32 [Bug c/95445] New: diagnose incompatible calls to functions declared without prototype msebor at gcc dot gnu.org 2020-05-30 22:32 ` [Bug c/95445] " msebor at gcc dot gnu.org 2021-10-27 5:21 ` egallager at gcc dot gnu.org @ 2023-05-12 15:54 ` fw at gcc dot gnu.org 2023-05-12 16:29 ` sjames at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: fw at gcc dot gnu.org @ 2023-05-12 15:54 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95445 Florian Weimer <fw at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fw at gcc dot gnu.org --- Comment #2 from Florian Weimer <fw at gcc dot gnu.org> --- Current Clang warns like this: t.c:17:5: warning: passing arguments to 'g' without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype] g (1); // (presumably) okay, f's type is 'void (int)' ^ t.c:18:5: warning: passing arguments to 'g' without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype] g ("foo"); // should be diagnosed ^ t.c:19:5: warning: passing arguments to 'g' without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype] g (1, "bar"); // ditto ^ Maybe that's sufficient? Trying to infer the type of g from its uses seems to be rather questionable. For K&R projects, GCC already has -flto -Wlto-type-mismatch, which can diagnose violations across translation units. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/95445] diagnose incompatible calls to functions declared without prototype 2020-05-30 22:32 [Bug c/95445] New: diagnose incompatible calls to functions declared without prototype msebor at gcc dot gnu.org ` (2 preceding siblings ...) 2023-05-12 15:54 ` fw at gcc dot gnu.org @ 2023-05-12 16:29 ` sjames at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: sjames at gcc dot gnu.org @ 2023-05-12 16:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95445 Sam James <sjames at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=108694 --- Comment #3 from Sam James <sjames at gcc dot gnu.org> --- I don't think we need to go beyond that (I don't really care about the uses). That'll make this a dupe of/depends on PR108694? ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-05-12 16:29 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-05-30 22:32 [Bug c/95445] New: diagnose incompatible calls to functions declared without prototype msebor at gcc dot gnu.org 2020-05-30 22:32 ` [Bug c/95445] " msebor at gcc dot gnu.org 2021-10-27 5:21 ` egallager at gcc dot gnu.org 2023-05-12 15:54 ` fw at gcc dot gnu.org 2023-05-12 16:29 ` sjames at gcc dot gnu.org
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).