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

           Summary: Using declaration of a dependent name
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ilpoil...@hotmail.com


Consider the following code:

template <typename T>
class A {public: typedef int C;};

template <typename T>
class B: public A<T> 
{
public:
    using typename A<T>::C;
    C operator[](int i) const { return 0; }
};

int main()
{
    B<int> b;
    b[2];
    return 0;
}

The compilation gives:

test.cpp:9: error: ISO C++ forbids declaration of 'C' with no type
test.cpp:9: error: expected ';' before 'operator'
test.cpp:10: error: expected ';' before '}' token
test.cpp: In function 'int main()':
test.cpp:15: error: no match for 'operator[]' in 'b[2]'

A discussion in comp.lang.c++ revealed that this feature was underspecified in
C++03. I propose the using declaration either just to work, or report a proper
error.

To see the intent, consider the current wording for C++0x:

From n3126 (C++0x draft from August 2010), ยง7.3.3:

"20. If a using-declaration uses the keyword typename and specifies a 
dependent name (14.6.2), the name introduced
by the using-declaration is treated as a typedef-name (7.1.3)."

So the work-around here is 

typedef typename A<T>::C C;

which is equivalent.

The code above is accepted at least by Visual Studio 2008, 2010, and Comeau
C++, all in strict mode.

Reply via email to