public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45625] New: Template parameter name does not hide outer class scope's member name
@ 2010-09-09 23:25 boostcpp at gmail dot com
2010-09-09 23:51 ` [Bug c++/45625] " redi at gcc dot gnu dot org
2010-09-22 15:58 ` gcc at magfr dot user dot lysator dot liu dot se
0 siblings, 2 replies; 7+ messages in thread
From: boostcpp at gmail dot com @ 2010-09-09 23:25 UTC (permalink / raw)
To: gcc-bugs
Consider following code.
struct Outer
{
static const int value = 1 ;
template< int value >
struct Inner
{
static const int inner_value = value ;
static int get_value() { return value ; } // which value?
} ;
} ;
int main()
{
typedef Outer::Inner<2> type ;
type::inner_value ; // 2. value is template parameter name.
type::get_value() ; // 1. value is Outer::value.
}
For Outer::Inner<2>, template parameter name "value" is 2.
Outer::Inner<2>::inner_value is evaluated to 2.
But Outer::Inner<2>::get_value() is evaluated to 1.
It looks like gcc lookup Outer::value for unqualified name value in the
function body scope of get_value().
Is it a correct behavior?
I think template parameter name of Inner should hide the Outer::value.
--
Summary: Template parameter name does not hide outer class
scope's member name
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: boostcpp at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45625
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/45625] Template parameter name does not hide outer class scope's member name
2010-09-09 23:25 [Bug c++/45625] New: Template parameter name does not hide outer class scope's member name boostcpp at gmail dot com
@ 2010-09-09 23:51 ` redi at gcc dot gnu dot org
2010-09-22 15:58 ` gcc at magfr dot user dot lysator dot liu dot se
1 sibling, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-09-09 23:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from redi at gcc dot gnu dot org 2010-09-09 23:51 -------
I agree the lookup in get_value should find the template parameter, not
Outer::value.
Here's a variation that should not compile, because &value should be invalid
struct Outer
{
static const int value = 1 ;
template< int value >
struct Inner
{
static const int* get_value() { return &value ; }
} ;
} ;
template class Outer::Inner<2>;
--
redi at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-09-09 23:51:26
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45625
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/45625] Template parameter name does not hide outer class scope's member name
2010-09-09 23:25 [Bug c++/45625] New: Template parameter name does not hide outer class scope's member name boostcpp at gmail dot com
2010-09-09 23:51 ` [Bug c++/45625] " redi at gcc dot gnu dot org
@ 2010-09-22 15:58 ` gcc at magfr dot user dot lysator dot liu dot se
1 sibling, 0 replies; 7+ messages in thread
From: gcc at magfr dot user dot lysator dot liu dot se @ 2010-09-22 15:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from gcc at magfr dot user dot lysator dot liu dot se 2010-09-22 15:58 -------
*** Bug 45747 has been marked as a duplicate of this bug. ***
--
gcc at magfr dot user dot lysator dot liu dot se changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gcc at magfr dot user dot
| |lysator dot liu dot se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45625
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/45625] Template parameter name does not hide outer class scope's member name
[not found] <bug-45625-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2011-08-18 7:42 ` dodji at gcc dot gnu.org
@ 2011-08-18 8:24 ` dodji at gcc dot gnu.org
3 siblings, 0 replies; 7+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-08-18 8:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45625
Dodji Seketeli <dodji at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #5 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-08-18 08:14:27 UTC ---
Fixed in trunk (4.7)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/45625] Template parameter name does not hide outer class scope's member name
[not found] <bug-45625-4@http.gcc.gnu.org/bugzilla/>
2011-08-17 14:58 ` dodji at gcc dot gnu.org
2011-08-17 19:03 ` dodji at gcc dot gnu.org
@ 2011-08-18 7:42 ` dodji at gcc dot gnu.org
2011-08-18 8:24 ` dodji at gcc dot gnu.org
3 siblings, 0 replies; 7+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-08-18 7:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45625
--- Comment #4 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-08-18 06:44:27 UTC ---
Author: dodji
Date: Thu Aug 18 06:44:22 2011
New Revision: 177846
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177846
Log:
PR c++/45625 - Template parm name doesn't hide outer class scope's member name
gcc/cp/
* pt.c (parameter_of_template_p): Handle comparison with DECLs of
template parameters as created by process_template_parm.
gcc/testsuite/
* g++.dg/lookup/hidden-var1.C: New test case.
Added:
trunk/gcc/testsuite/g++.dg/lookup/hidden-var1.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/45625] Template parameter name does not hide outer class scope's member name
[not found] <bug-45625-4@http.gcc.gnu.org/bugzilla/>
2011-08-17 14:58 ` dodji at gcc dot gnu.org
@ 2011-08-17 19:03 ` dodji at gcc dot gnu.org
2011-08-18 7:42 ` dodji at gcc dot gnu.org
2011-08-18 8:24 ` dodji at gcc dot gnu.org
3 siblings, 0 replies; 7+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-08-17 19:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45625
--- Comment #3 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-08-17 18:57:52 UTC ---
Candidate fix posted to http://gcc.gnu.org/ml/gcc-patches/2011-08/msg01418.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/45625] Template parameter name does not hide outer class scope's member name
[not found] <bug-45625-4@http.gcc.gnu.org/bugzilla/>
@ 2011-08-17 14:58 ` dodji at gcc dot gnu.org
2011-08-17 19:03 ` dodji at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: dodji at gcc dot gnu.org @ 2011-08-17 14:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45625
Dodji Seketeli <dodji at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC|dodji at gcc dot gnu.org |
AssignedTo|unassigned at gcc dot |dodji at gcc dot gnu.org
|gnu.org |
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-08-18 8:16 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-09 23:25 [Bug c++/45625] New: Template parameter name does not hide outer class scope's member name boostcpp at gmail dot com
2010-09-09 23:51 ` [Bug c++/45625] " redi at gcc dot gnu dot org
2010-09-22 15:58 ` gcc at magfr dot user dot lysator dot liu dot se
[not found] <bug-45625-4@http.gcc.gnu.org/bugzilla/>
2011-08-17 14:58 ` dodji at gcc dot gnu.org
2011-08-17 19:03 ` dodji at gcc dot gnu.org
2011-08-18 7:42 ` dodji at gcc dot gnu.org
2011-08-18 8:24 ` dodji at gcc dot gnu.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).