public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12341] Request for additional warning for variable shadowing
       [not found] <bug-12341-4@http.gcc.gnu.org/bugzilla/>
@ 2020-05-18 23:43 ` msebor at gcc dot gnu.org
  2021-10-25  5:10 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-05-18 23:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12341

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |87403
   Last reconfirmed|2005-12-11 23:28:15         |2020-5-18
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Reconfirming with GCC 11.0.


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] 7+ messages in thread

* [Bug c++/12341] Request for additional warning for variable shadowing
       [not found] <bug-12341-4@http.gcc.gnu.org/bugzilla/>
  2020-05-18 23:43 ` [Bug c++/12341] Request for additional warning for variable shadowing msebor at gcc dot gnu.org
@ 2021-10-25  5:10 ` pinskia at gcc dot gnu.org
  2022-02-04  7:52 ` egallager at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-25  5:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12341

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joseph.h.garvin at gmail dot com

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 45615 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/12341] Request for additional warning for variable shadowing
       [not found] <bug-12341-4@http.gcc.gnu.org/bugzilla/>
  2020-05-18 23:43 ` [Bug c++/12341] Request for additional warning for variable shadowing msebor at gcc dot gnu.org
  2021-10-25  5:10 ` pinskia at gcc dot gnu.org
@ 2022-02-04  7:52 ` egallager at gcc dot gnu.org
  2022-02-04 11:00 ` redi at gcc dot gnu.org
  2023-04-07 13:29 ` priour.be at gmail dot com
  4 siblings, 0 replies; 7+ messages in thread
From: egallager at gcc dot gnu.org @ 2022-02-04  7:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12341

--- Comment #5 from Eric Gallager <egallager at gcc dot gnu.org> ---
is this expected to be a new argument accepted by the `-Wshadow=` flag, or its
own separate flag entirely?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/12341] Request for additional warning for variable shadowing
       [not found] <bug-12341-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2022-02-04  7:52 ` egallager at gcc dot gnu.org
@ 2022-02-04 11:00 ` redi at gcc dot gnu.org
  2023-04-07 13:29 ` priour.be at gmail dot com
  4 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-04 11:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12341

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This inheritance case is "name hiding" and we have other requests for warnings
about it. I think it should be distinct from -Wshadow.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/12341] Request for additional warning for variable shadowing
       [not found] <bug-12341-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2022-02-04 11:00 ` redi at gcc dot gnu.org
@ 2023-04-07 13:29 ` priour.be at gmail dot com
  4 siblings, 0 replies; 7+ messages in thread
From: priour.be at gmail dot com @ 2023-04-07 13:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12341

Benjamin Priour <priour.be at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |priour.be at gmail dot com

--- Comment #7 from Benjamin Priour <priour.be at gmail dot com> ---
Hi,

I'm currently fixing this, I've put it under -Wshadow for now, as it is still
about shadowing names, but I could add a -Wname-hiding or something akin to it.

What about the visibility of the base class field ?

I think that in snippet (1) below, a warning should be issued, as we can
imagine Base being virtual with private field x and a friend function
foo(Base*) taking polymorphic argument Base*, then Derived inherits of Base,
with public field x.
There might be an ambiguity upon accessing x in a call to foo((Base *)
derived).

Therefore, I believe the warning should be issued no matter the visibility of
the fields within the parent's class.

However, if Grandpa class is privately inherited by Base class, then I'd expect
Derived to not issue warnings for its fields named only after Grandpa's.


// Snippet (1)
class Base {
private:
  int x;
};
class Derived : public Base {
public:
 int x; // issue warning despite Base::x private
};

// Snippet (2)
class Grandpa;
class Base : private Grandpa;
class Derived : public Base; // No warnings emitted for eponymous fields of
Grandpa's

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/12341] Request for additional warning for variable shadowing
       [not found] <bug-12341-5606@http.gcc.gnu.org/bugzilla/>
@ 2005-12-13  9:18 ` hayim at dv-networks dot com
  0 siblings, 0 replies; 7+ messages in thread
From: hayim at dv-networks dot com @ 2005-12-13  9:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from hayim at dv-networks dot com  2005-12-13 09:17 -------
I agree.
I hope this warning will be added in near future versions of g++.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12341


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/12341] Request for additional warning for variable shadowing
  2003-09-19 16:01 [Bug c++/12341] New: " bero at arklinux dot org
@ 2003-09-19 19:23 ` bangerth at dealii dot org
  0 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2003-09-19 19:23 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12341


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-09-19 17:57:14
               date|                            |


------- Additional Comments From bangerth at dealii dot org  2003-09-19 17:57 -------
Right. Makes sense. 
W.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-04-07 13:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-12341-4@http.gcc.gnu.org/bugzilla/>
2020-05-18 23:43 ` [Bug c++/12341] Request for additional warning for variable shadowing msebor at gcc dot gnu.org
2021-10-25  5:10 ` pinskia at gcc dot gnu.org
2022-02-04  7:52 ` egallager at gcc dot gnu.org
2022-02-04 11:00 ` redi at gcc dot gnu.org
2023-04-07 13:29 ` priour.be at gmail dot com
     [not found] <bug-12341-5606@http.gcc.gnu.org/bugzilla/>
2005-12-13  9:18 ` hayim at dv-networks dot com
2003-09-19 16:01 [Bug c++/12341] New: " bero at arklinux dot org
2003-09-19 19:23 ` [Bug c++/12341] " bangerth at dealii dot 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).