public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/41825]  New: useless -Wshadow warning on function argument in local class
@ 2009-10-25 20:06 msebor at gmail dot com
  2009-10-26  4:52 ` [Bug c++/41825] " bangerth at gmail dot com
  2010-05-07 13:57 ` jason at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: msebor at gmail dot com @ 2009-10-25 20:06 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]

The warning on the code below isn't useful since the formal argument of foo()
named i cannot be referenced in the body of the local struct. I.e., there is
no potential for referring to it by mistake since doing so would be a hard
error.

$ cat t.cpp && g++ -c -Wshadow t.cpp
int foo (int i)
{
    struct {
        int bar (int i) { return i; }
    } s;

    return s.bar (i);
};
t.cpp: In member function ‘int foo(int)::<anonymous struct>::bar(int)’:
t.cpp:4: warning: declaration of ‘int i’ shadows a parameter
t.cpp:1: warning: shadowed declaration is here


-- 
           Summary: useless -Wshadow warning on function argument in local
                    class
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: msebor at gmail dot com
 GCC build triplet: all
  GCC host triplet: all
GCC target triplet: all


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


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

* [Bug c++/41825] useless -Wshadow warning on function argument in local class
  2009-10-25 20:06 [Bug c++/41825] New: useless -Wshadow warning on function argument in local class msebor at gmail dot com
@ 2009-10-26  4:52 ` bangerth at gmail dot com
  2010-05-07 13:57 ` jason at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: bangerth at gmail dot com @ 2009-10-26  4:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at gmail dot com  2009-10-26 04:52 -------
Confirmed. Though I'd note that if this was a *nested* function (not a function
in a *nested structure*) -- or a lambda function--, then the warning would make
sense.


-- 

bangerth at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at gmail dot com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-10-26 04:52:41
               date|                            |


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


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

* [Bug c++/41825] useless -Wshadow warning on function argument in local class
  2009-10-25 20:06 [Bug c++/41825] New: useless -Wshadow warning on function argument in local class msebor at gmail dot com
  2009-10-26  4:52 ` [Bug c++/41825] " bangerth at gmail dot com
@ 2010-05-07 13:57 ` jason at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-07 13:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jason at gcc dot gnu dot org  2010-05-07 13:57 -------


*** This bug has been marked as a duplicate of 30566 ***


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2010-05-07 13:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-25 20:06 [Bug c++/41825] New: useless -Wshadow warning on function argument in local class msebor at gmail dot com
2009-10-26  4:52 ` [Bug c++/41825] " bangerth at gmail dot com
2010-05-07 13:57 ` jason at gcc dot gnu 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).