fac*_*tus 17 c++ visual-studio-2013
请考虑以下代码:
#include <iostream>
struct A {};
struct B {};
int func1(A *a, B *b, int c, double *d) {
int tmp = 0;
tmp = tmp;
return 1;
}
int func2(A *a, B *b, int c, double *d) {
return 1;
}
int main(int argc, char* argv[]) {
if (func1 == func2) {
std::cout << "equal" << std::endl;
} else {
std::cout << "not equal" << std::endl;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在VS2013中的Release配置中编译时,它打印出"相等".我有一个库,它依赖于函数地址的比较.您可以想象它在Release中不起作用.有没有办法阻止VC++中的这种优化?或者我应该提交错误?