If I try compile the following and I have /O2 optimisation on, then it doesn't compile:
#include <math.h>
double myfunc(double arg) { return 5.4; };
double (*f[])(double) = {
myfunc,
fabs,
// floor, // THESE TWO TRIGGER THE ERROR
// ceil, // initialiser is not a constant
sqrt
};
Only the floor and ceil functions trigger the error. If I put this code in a cpp file it compiles fine, but it seems MSVC's compiler is bugged, or am I doing something wrong? Error only happens on /O2, not /O1 or disabled. I'm on Visual Studio Version 17.7.6. Windows SDK version is 10.0 (latest installed version).
It is unrelated to the optimisation settings.
It is only because of the Enable Intrinsic Functions settings. If you set this to NO, it compiles fine. With this setting set to Yes (/Oi) I get the same errors.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With