This code crashes VisualC++2005 express when cmath is not included:
Any computation before or after the cos() call crashes it but removing it wont.Code:static void GetTimedAlpha() { int(cos(1) + 1); }
Can anyone confirm if this works in 2008?
This code crashes VisualC++2005 express when cmath is not included:
Any computation before or after the cos() call crashes it but removing it wont.Code:static void GetTimedAlpha() { int(cos(1) + 1); }
Can anyone confirm if this works in 2008?
I can confirm the crash in VS2005, but I'm just a few days away of having VS2008 Express installed. The static part isn't needed to produce the crash if you simply make it a global function, and the function names make no difference.Same crash.Code:void foo() { int(bar(1) + 1); }
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
That's a rather startling bug. I verified that it crashes VS2005.
I tried VS2008 and it does not crash. Instead I get the expected:
I bet the bug has something to do with the compiler not knowing whether cos(1) is a function invokation or a constructor call to create a temporary. Somehow, making this part of a compound expression makes it gag and blow up.1>c:\othercode\crashvs2005\crash\crash.cpp(3) : error C3861: 'cos': identifier not found
The equivalent in C does not crash:
Terrible, terrible bug.Code:int foo() { (int)(cos(1)+1); }
Also, I notice that using (int) instead of int() makes the crash go away in C++.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
Because VS2008 is certainly free of bugs?
It's usually a mistake to change a working system. In a real environment, a change like upgrading the compiler might take months of testing before being put into production.
This bug seems pretty awful, but it's a weird boundary case.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}