我正在Windows 10上使用Clang版本10.0.0。
此程序
#include <iostream>
// without this operator the program works just fine
void* operator new(std::size_t nrOfBytes) {
std::cout << "allocate " << nrOfBytes << " bytes on heap" << std::endl;
void* p = malloc(nrOfBytes);
if (p) {
return p;
} else {
throw std::bad_alloc{};
}
}
int main() {
printf("START\n");
return 0;
}
使用]编译后,崩溃,返回码-1073741819>
clang ++ Main.cpp -std = c ++ 17
当然,当没有重载的新运算符时,对clang的完全相同的调用会生成无错误的程序。
有任何提示吗?
我在Windows 10上使用的是Clang版本10.0.0。