I have a pretty weird ‘crash’ at a customer’s computer. Using logs I was able to track it to this line of code:
myvar = 1; //This ‘crashes’. myvar is declared as ‘double’
The code is obviously okay. But myvar is a member variable of a class. And there is a global instance of this variable and line of code is in the constructor. So it’s executed before main(). Not good style, I know…
My questions:
– Is it allowed to use float/double before main()?
– Is there some kind of “InitFloatSystem()” function that I could call?
Some more info:
– It’s a Win32 / C++
– There’s no crash message, the program just closes
– try/catch doesn’t help
I’m really out of ideas…
Finally, finally found the problem. It’s an issue of Visual Studio 2012. I found at the Microsoft website, even though they reported different side effects: http://connect.microsoft.com/VisualStudio/feedback/details/771122/floating-point-math-change-from-vs2008-to-vs2012-affects-native-code-but-not-managed-code
My guess is that the compiler now uses by default processor features that aren’t available on some old processors. Using this compiler option magically fixed it:
/arch:IA32