C++ g+中的另一个bug+/叮当声?[C+;+;模板很有趣]

C++ g+中的另一个bug+/叮当声?[C+;+;模板很有趣],c++,templates,C++,Templates,查看以下代码(仅为好玩而编写) 名称空间N { 模板 结构K { }; } 模板 结构X { typename T::template K*p;//应该给出错误 //N::K没有名为'K'的模板成员` }; int main() { xl; } >代码在G++(4.5.1)和CLAN上编译,而COMMO和英特尔C++给出(类似)错误。 我在Comeau上遇到的错误有: "ComeauTest.c", line 13: error: class "N::K<int>" has no

查看以下代码(仅为好玩而编写)

名称空间N
{
模板
结构K
{
};
}
模板
结构X
{
typename T::template K*p;//应该给出错误
//N::K没有名为'K'的模板成员`
};
int main()
{
xl;
}
<> >代码在G++(4.5.1)和CLAN上编译,而COMMO和英特尔C++给出(类似)错误。 我在Comeau上遇到的错误有:

"ComeauTest.c", line 13: error: class "N::K<int>" has no member "K"
     typename T::template K<T> *p;
                          ^
          detected during instantiation of class "X<T> [with T=N::K<int>]" at
                    line 18

"ComeauTest.c", line 13: error: expected an identifier
     typename T::template K<T> *p;
                           ^
          detected during instantiation of class "X<T> [with T=N::K<int>]" at
                    line 18
“ComeauTest.c”,第13行:错误:类“N::K”没有成员“K”
类型名T::模板K*p;
^
在实例化类“X[带T=N::K]”时检测到
第18行
“ComeauTest.c”,第13行:错误:应为标识符
类型名T::模板K*p;
^
在实例化类“X[带T=N::K]”时检测到
第18行
所以我的问题是“代码样本是否格式错误?”根据我的回答是“是”。这是否意味着这是g++/Clang中的另一个bug?

为什么GCC和Clang认为它们是正确的
K
是注入的类名,在
K
的范围内具有双重性质。您可以在没有模板参数的情况下使用它。然后它引用
K
(它自己的类型)


它后面还可以跟一个模板参数列表。在我看来,有理由说您需要在它前面加上
template
,因为解析器对
的解释很模糊!没什么可说的了!这怎么“不是一个真正的问题”?你们这些家伙怎么了?谁投票把这个关闭为“不是真正的问题”,就不要再去试图去过滤C++模板,回到他们的java IDE。这是什么时候开始在我的编译器中出现的错误?不是真正的问题吗?
"ComeauTest.c", line 13: error: class "N::K<int>" has no member "K"
     typename T::template K<T> *p;
                          ^
          detected during instantiation of class "X<T> [with T=N::K<int>]" at
                    line 18

"ComeauTest.c", line 13: error: expected an identifier
     typename T::template K<T> *p;
                           ^
          detected during instantiation of class "X<T> [with T=N::K<int>]" at
                    line 18
template <class T> struct Base { };
template <class T> struct Derived: Base<int>, Base<char> {
   typename Derived::Base b; // error: ambiguous
   typename Derived::Base<double> d; // OK
};
// just replace struct X with this:
template<typename T>
struct X
{
   struct Derived : T { };
   typename Derived::template K<T> *p;
};
"ComeauTest.c", line 13: error: overloaded function "N::K<T>::K [with T=int]" is
          not a template
     typename T::template K<T> *p;