public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/104379] [9/10/11/12 Regression] -Wshadow warning given three times
Date: Fri, 04 Feb 2022 12:06:18 +0000 [thread overview]
Message-ID: <bug-104379-4-GXgNBGbP1s@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104379-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104379
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> I suppose the same issue might happen with templates where we'd warn
> once per instantiation?
Yes indeed. Once for the primary template, and then again for each
specialization generated from it:
template<typename T>
struct S
{
int i;
int f(int i) { return i; }
};
int i = S<int>().f(1);
int j = S<long>().f(1);
shad2.C: In member function ‘int S<T>::f(int)’:
shad2.C:5:13: warning: declaration of ‘i’ shadows a member of ‘S<T>’ [-Wshadow]
5 | int f(int i) { return i; }
| ~~~~^
shad2.C:4:7: note: shadowed declaration is here
4 | int i;
| ^
shad2.C: In instantiation of ‘int S<T>::f(int) [with T = int]’:
shad2.C:8:19: required from here
shad2.C:5:13: warning: declaration of ‘i’ shadows a member of ‘S<int>’
[-Wshadow]
5 | int f(int i) { return i; }
| ~~~~^
shad2.C:4:7: note: shadowed declaration is here
4 | int i;
| ^
shad2.C: In instantiation of ‘int S<T>::f(int) [with T = long int]’:
shad2.C:9:20: required from here
shad2.C:5:13: warning: declaration of ‘i’ shadows a member of ‘S<long int>’
[-Wshadow]
5 | int f(int i) { return i; }
| ~~~~^
shad2.C:4:7: note: shadowed declaration is here
4 | int i;
| ^
next prev parent reply other threads:[~2022-02-04 12:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 11:12 [Bug c++/104379] New: [p/10/11/12 " redi at gcc dot gnu.org
2022-02-04 11:13 ` [Bug c++/104379] [9/10/11/12 " redi at gcc dot gnu.org
2022-02-04 11:20 ` redi at gcc dot gnu.org
2022-02-04 11:47 ` rguenth at gcc dot gnu.org
2022-02-04 11:54 ` rguenth at gcc dot gnu.org
2022-02-04 12:06 ` redi at gcc dot gnu.org [this message]
2022-02-04 12:07 ` redi at gcc dot gnu.org
2022-02-04 13:29 ` rguenther at suse dot de
2022-02-04 13:32 ` rguenth at gcc dot gnu.org
2022-02-07 14:07 ` jakub at gcc dot gnu.org
2022-02-08 19:18 ` cvs-commit at gcc dot gnu.org
2022-02-08 19:20 ` [Bug c++/104379] [9/10/11 " jakub at gcc dot gnu.org
2022-02-09 7:18 ` rguenther at suse dot de
2022-05-27 9:47 ` [Bug c++/104379] [10/11 " rguenth at gcc dot gnu.org
2022-06-28 10:47 ` jakub at gcc dot gnu.org
2023-07-07 10:42 ` [Bug c++/104379] [11 " rguenth 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-104379-4-GXgNBGbP1s@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: link
Be 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).