编译器发生内部错误
C1001: An internal error has occurred in the compiler
这应该不言自明。我试图实现一个分布排序,和MSVC编译器崩溃。这似乎是我的SFINAE检测成员函数的特定情况,如果我不将indexert传递给函数,也不替换has_get_index,这似乎不会发生。如果我删除任何一个剩余的索引器重载,也不会发生这种情况。如果sortable有一个getIndex() const
成员,这个问题仍然存在。
1>test.cpp(34): 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.
(没有"上面列出的位置")一个最小的测试用例是:
#include <vector>
#include <iterator>
#include <type_traits>
#ifndef HAS_MEM_FUNC //SFINAE (or maybe it is?)
#define HAS_MEM_FUNC(name, func)
template<typename T>
struct name {
typedef char yes[1];
typedef char no [2];
template <typename C> static yes& test( typename C::func ) ;
template <typename C> static no& test(...);
static bool const value = sizeof(test<T>(0)) == sizeof(yes);
}
#endif
HAS_MEM_FUNC(has_get_index,getIndex);
//default indexer undefined
template <class T>
double indexer(...);
//indexer for objects that have a "T::getIndex() const" member
template <class T>
double indexer(const typename std::enable_if<has_get_index<T>::value,T>::type& b) {
return b.getIndex();
};
template<class indexert>
void function(indexert indexeri)
{}
struct sortable {};
int main () {
function(indexer<sortable>); //line 34
}
这可能不是你想要的:
template <typename C> static yes& test( typename C::func ) ;
对于typename
,您告诉编译器C::func
将是一个类型。实际上,它将是一个函数,在形参声明中放置函数名没有任何意义。
您是否打算使用typeof
而不是typename
?
相关文章:
- spdlog标头仅与外部fmt一起使用.spdlog错误:'内部':不是'fmt'
- 方法内部但循环仍得到预期的不合格id错误C++
- C++代码停止工作错误使用cout内部函数
- C1001内部编译器错误是由于矢量初始化(如数组)引起的
- 致命错误 C1001 :vs2017 15.8.4 的内部错误(编译器文件"msc1.cpp",第
- mingw32_gt_pch_use_address中的内部错误,在config/i386/host-mingw32.c
- C++:在"try"外部创建的类型会导致错误,但在内部不会
- 在另一个结构中声明内部结构会导致错误:结构使用无效
- 有关使用标志位设置内部错误标志的说明
- OpenMP 会导致内部编译器错误
- 内部编译器错误Visual Studio Community 2017与SFML API
- 致命错误 C1001:编译器中发生内部错误。'f:\dd\VCtools\Compiler\cxFE\SL\P1\C\P0io.c'
- 作为 int 传递和类内部指针之间的差异给我带来了分段错误
- 在尝试在同一类内部进行课程矢量时,我会遇到错误
- GCC(通过 CUDA)内部函数的编译器错误,但我没有使用任何
- 为什么在匿名名称空间中定义的模板时,为什么内部链接错误
- 在函数内部错误定位后,从函数中释放返回的指针会导致芯片崩溃
- "如果 constexpr",在 lambda 内部,在包扩展内部 - 编译器错误?
- G :内部编译器错误:分割故障(程序CC1PLUS) - 我在哪里开始
- VS2008 中的简单 swig python 示例 - 导入错误 - 内部 (py)readline 错误