Coffeehouse Thread

7 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

VS 2003 ... Houston, we have a problem...

Back to Forum: Coffeehouse
  • User profile image
    Minh

    I think I found a bug with VS 2003 SP1 (v 7.1.6030) running on top of the CLR 1.1 SP1 (1.1.4322).

    It'd be great if someone can confirm this w/ VS 2003 also.

    When "Optimize Code" is set to "true" (Release build), case "0" and case "1", both execute in the following code:

    So in Debug build, we get:

    > Zero

    And in the Release build, we get:

    > Zero ********** OMG **********

    Scary, eh?
    ----------

        public class Program
        {
            public Program()
            {
            }

            public static void Main()
            {
                string status = "";
                int i = 0;

                switch (i)
                {
                    case 0:
                        try
                        {
                        }
                        catch
                        {
                        }
                        finally
                        {
                            status += "Zero";
                        }
                        break;

                    case 1:
                        status += " ********** OMG **********";
                        break;
                }

                Console.WriteLine(status);
            }
        }

  • User profile image
    W3bbo

    I can confirm

    I took a gander at the disassembly:

    public static void Main()
    {
    string str = "";
    switch (0)
    {
    case 0:
    str = str + "Zero";
    break;

    case 1:
    break;

    default:
    goto Label_0032;
    }
    str = str + " ********** OMG **********";
    Label_0032:
    Console.WriteLine(str);
    Console.ReadLine();
    }

    figures...

    It's not a bug with the CLR or IDE, but with the compiler

  • User profile image
    Minh

    I guess the good news is that it doesn't happen in VS 2005... but I wonder how many people are like me? I have to stay w/ 2003. And SP1 is the latest SP out there for 2003.


  • User profile image
    ScanIAm

    Try adding a default: case to your original switch and see if things are any different.

    It looks like the compiler felt the need to put a default in there, so maybe you should, also.

    I'll be the first to admit that I skip it sometimes, but I thought it was required back in c/c++.

  • User profile image
    Minh

    having a default: case still causes the bug to appear.

    MS, you owe me $$$ for many hours looking for this bug. Please post the address where I can send the invoice.

    PS:

    I'm not sure why a Google image search for "lolcatz begging" returns this one:


    ">http://www.neopoleon.com/home/images/banner.jpg">

  • User profile image
    W3bbo

    Minh wrote:
    I guess the good news is that it doesn't happen in VS 2005... but I wonder how many people are like me? I have to stay w/ 2003. And SP1 is the latest SP out there for 2003.


    SP1 didn't change the compiler, I don't think.

    Besides, this has been out long enough for Microsoft to not want to make any changes, since there might be software out there that takes account of this bug. Any change in the behaviour of the compiler would break those apps.

    EDIT:

    Try this in VBC and see if it affects that. At least it doesn't affect the CIL compiler.

  • User profile image
    Minh

    W3bbo wrote:
    
    Besides, this has been out long enough for Microsoft to not want to make any changes, since there might be software out there that takes account of this bug. Any change in the behaviour of the compiler would break those apps.

    I don't think that true. You never ever want inconsistent result between Debug & Release.

    If a behavior was consistent, but wrong, I'd see a rationale in not fixing it. But inconsistent result is just plain bad.

    W3bbo wrote:
    Try this in VBC and see if it affects that. At least it doesn't affect the CIL compiler.
    Nah. Too lazy. Moral of the story: Don't use VS 2003. If you have to, turn off optimization.


Conversation locked

This conversation has been locked by the site admins. No new comments can be made.