public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "nightstrike at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/103996] New: Enhancement: Better diagnostic for invalid reuse of a function name Date: Wed, 12 Jan 2022 18:13:05 +0000 [thread overview] Message-ID: <bug-103996-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103996 Bug ID: 103996 Summary: Enhancement: Better diagnostic for invalid reuse of a function name Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: nightstrike at gmail dot com Target Milestone: --- Related email thread: https://gcc.gnu.org/pipermail/gcc-help/2022-January/141117.html I recently hit this problem: #include <strings.h> void f() { index[0] = 0; } #gcc is 11.2.0 gcc -c a.c a.c:4:7: error: subscripted value is neither array nor pointer nor vector 4 | index[1] = 0; | ^ I could not find a compiler option that would tell me what the root cause was. I wasn't getting a simple "undeclared" error, so I surmised the name must already be in use, but I was confused as to how or where it was being used. My first thought was that maybe index was a global variable, so I tried using -Wshadow. Eventually, I found that it was a function from strings.h which was included several layers down an include spiral. I think an effective note from gcc such as "index was previously declared here as a function", or something similar that often happens in other diagnostics, would aid in finding the root cause of my bug. Incidentally, in my actual scenario, the real bug was that I forgot to access index as a member of a struct: x.index vs index. But I'd wager that expecting GCC to look for all nearby structs for a similarly named member is unreasonable. Simply telling me where index originates, though, would have helped greatly.
next reply other threads:[~2022-01-12 18:13 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-12 18:13 nightstrike at gmail dot com [this message] 2022-01-12 18:15 ` [Bug c/103996] " pinskia at gcc dot gnu.org 2022-01-12 18:23 ` pinskia at gcc dot gnu.org 2022-01-12 18:38 ` [Bug c/103996] Provide " pinskia at gcc dot gnu.org 2022-01-13 11:40 ` egallager 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-103996-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).