首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Visual C++ 10.0 SP1中的编译器错误- cl.exe版本16.0.40219.1访问冲突[已确认]

Visual C++ 10.0 SP1中的编译器错误- cl.exe版本16.0.40219.1访问冲突[已确认]
EN

Stack Overflow用户
提问于 2013-09-12 21:02:29
回答 2查看 1K关注 0票数 18

我在使用Visual Stuido 2010 SP1,cl.exe版本16.0.40219.1编译一些模板代码时遇到了问题

下面的代码将导致编译器访问violate:

template<typename T>
class A
{
    A(){}
};

template<typename T>
class B : public A<T>
{
    using A::A(); // Compiler access violates
    // **EDIT**
    //using A<T>::A<T>; // Compiler succeeds
    //using A<T>::A(); // Compiler reports error
};

int main(int argc, char* argv[])
{
    return 0;
}

它会生成以下错误(除了"cl.exe已停止工作,C0000005异常“):

1>d:\projects\cpptest\cpptest\cpptest.cpp(11): fatal error C1001: An internal error has occurred in the compiler.
1>  (compiler file 'msc1.cpp', line 1420)
1>   To work around this problem, try simplifying or changing the program near the locations listed above.

在使用g++的Dev-C++中,代码可以很好地编译(也就是说,它会发出正确的错误消息,并且不会使编译器崩溃)。

main.cpp:11: error: `template<class T> class A' used without template parameters
main.cpp:11: error: expected nested-name-specifier before "A"
main.cpp:11: error: using-declaration for non-member at class scope
main.cpp:11: error: expected `;' before '(' token
main.cpp:11: error: expected unqualified-id before ')' token
make.exe: *** [main.o] Error 1

编辑以下内容,但是,编译良好,没有访问冲突,所以这似乎与模板有关:

class A
{
    A(){}
};

class B : public A
{
    using A::A;
};

int main(int argc, char* argv[])
{
    return 0;
}

你认为这值得向微软报告吗?其他人能复制这个吗?也许可以在Visual Studio 2013中尝试一下,看看它是否仍然会发生?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-09-12 22:48:13

因为这可以被Visual C++平台上的其他人重现,所以我在Microsoft Connect上打开了一个错误报告"answer“。

此外,作为解决方法,可以使用以下语法:

using A<T>::A<T>;
票数 4
EN

Stack Overflow用户

发布于 2013-12-07 03:11:31

更新2013-12-06:微软已确认该问题,该问题将在Visual Studio2013 C++编译器中修复。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18765097

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档