public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/95445] New: diagnose incompatible calls to functions declared without prototype Date: Sat, 30 May 2020 22:32:07 +0000 [thread overview] Message-ID: <bug-95445-4@http.gcc.gnu.org/bugzilla/> (raw) 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 (); | ^~~~~~
next reply other threads:[~2020-05-30 22:32 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-30 22:32 msebor at gcc dot gnu.org [this message] 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
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=bug-95445-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /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: linkBe 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).