internal compiler error VC++2005

This is a discussion on internal compiler error VC++2005 within the C++ Programming forums, part of the General Programming Boards category; This code crashes VisualC++2005 express when cmath is not included: Code: static void GetTimedAlpha() { int(cos(1) + 1); } Any ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    330

    internal compiler error VC++2005

    This code crashes VisualC++2005 express when cmath is not included:

    Code:
    static void GetTimedAlpha()
    {
    	int(cos(1) + 1);
    }
    Any computation before or after the cos() call crashes it but removing it wont.

    Can anyone confirm if this works in 2008?

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,304
    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.
    Code:
    void foo()
    {
    	int(bar(1) + 1);
    }
    Same crash.
    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"

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    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:

    1>c:\othercode\crashvs2005\crash\crash.cpp(3) : error C3861: 'cos': identifier not found
    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.

    The equivalent in C does not crash:

    Code:
    int foo()
    {
    	(int)(cos(1)+1);
    }
    Terrible, terrible bug.

    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);
    //}

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    VS2005 is a broken compiler. Upgrade.

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by Sebastiani View Post
    VS2005 is a broken compiler. Upgrade.
    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);
    //}

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by brewbuck View Post
    Because VS2008 is certainly free of bugs?
    I don't know about that, but I have heard that it's much more stable. Besides that, VS2005 struggles with standard compliance, and has problems processing C++ templates, which appear to have been (mostly) fixed with VS2008.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev C++ Compiler, Indentation?
    By Zeusbwr in forum C++ Programming
    Replies: 3
    Last Post: 10-21-2004, 06:13 AM
  2. lcc win32 compiler download problems
    By GanglyLamb in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-01-2004, 07:39 PM
  3. Special Compiler for win app's
    By Unregistered in forum Windows Programming
    Replies: 19
    Last Post: 04-26-2002, 03:52 PM
  4. fatal error C1001: INTERNAL COMPILER ERROR
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 04-21-2002, 12:07 PM
  5. MSVC 5/97 Internal Error c1001?????
    By novacain in forum Windows Programming
    Replies: 4
    Last Post: 10-31-2001, 11:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21