[Bug c++/13967] A warning could be emitted if a template parameter of a member template is begin shadowed by another member of the class

gdr at integrable-solutions dot net gcc-bugzilla@gcc.gnu.org
Mon Feb 2 21:08:00 GMT 2004


------- Additional Comments From gdr at integrable-solutions dot net  2004-02-02 21:08 -------
Subject: Re:  [3.3?/3.4/3.5 regression] template template argument identifier lookup fails scoping rules

"gianni at mariani dot ws" <gcc-bugzilla@gcc.gnu.org> writes:

| Giving this problem some more thought - I'm thinking that there
| should be some kind of diagnostic if a template parameter is hidden,
| at least a warning.

Sure, giving a warning controled by -Wshadow is a good idea 
(I've been thinking about that this morning while walking to work :-).

| The template parameter is useless (at least next to useless) if it's
| hidden and so this is probably not what the coder expected. 

Please remember that a template-parameter can be renammed at will.
In particular, there is no obligation that the template-parameter name
used in the declaration be the same as the one used in the definition.
And the definition can appear very far down in the program (or in
another translation unit.  You don't want the members be "leaked" by
whatever names are used in those definitions.

| I'm obviously not the only one who has been or is surprised by this
| behaviour. 

Well, we're talking about templates, right? :-)

-- Gaby


-- 


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



More information about the Gcc-bugs mailing list