This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/45625] New: Template parameter name does not hide outer class scope's member name


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]