Bug 32160 - g++ produces bogus warnings when -Wshadow is given
g++ produces bogus warnings when -Wshadow is given
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-03-18 17:30 EST by Wagner T. Correa
Modified: 2007-04-18 12:32 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-03-19 09:57:14 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Wagner T. Correa 2001-03-18 17:30:23 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.2.16-22smp i686)


According to the man page, the purpose of -Wshadow is to warn whenever a
local variable shadows another  local variable.  However, it also gives you
undesirable warnings when a local variable shadows a global variable.

Reproducible: Always
Steps to Reproduce:
Just compile the code below with g++ -Wshadow

#include <algorithm>
#include <string>

int main ()
{
	return 0;
}


Actual Results:  In file included from
/usr/include/g++-3/std/bastring.h:661,
                 from /usr/include/g++-3/string:7,
                 from y.cpp:3:
/usr/include/g++-3/std/bastring.cc: In function `istream &getline 
(istream &, basic_string<charT, traits, Allocator> &, charT)':
/usr/include/g++-3/std/bastring.cc:479: warning: declaration of `count'
shadows global declaration


Expected Results:  Since count is global, g++ should not issue that
warning.

Maybe -shadow should be split into two: -shadow-local and -shadow-global.
Comment 1 Jakub Jelinek 2001-03-19 09:57:05 EST
I've changed bastring.cc so that you don't get this warning for it.
Concerning behaviour of -Wshadow, the documentation is just incomplete,
gcc has been warning about shadowing many things for very long time and this
behaviour has not changed. E.g. it warns if a static function shadows
a builtin, local variable shadows a parameter etc.
Comment 2 Jakub Jelinek 2001-03-30 05:27:05 EST
These two changes are in gcc 2.96-80.

Note You need to log in before you can comment on or make changes to this bug.