From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E82B3388981D; Wed, 12 Jan 2022 18:13:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E82B3388981D From: "nightstrike at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nightstrike at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2022 18:13:06 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103996 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 void f() { index[0] =3D 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] =3D 0; | ^ I could not find a compiler option that would tell me what the root cause w= as.=20 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 h= ere as a function", or something similar that often happens in other diagnostic= s, would aid in finding the root cause of my bug. Incidentally, in my actual scenario, the real bug was that I forgot to acce= ss index as a member of a struct: x.index vs index. But I'd wager that expect= ing 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.=