This bug was found in 1.0 of the compiler by somebody else too:

see:

http://www.jelovic.com/weblog/e49.htm

and

http://groups.google.com/groups?hl=en&lr=&ie=UTF8&threadm=eySvl16JCH
A.2240%40tkmsftngp13&rnum=1&prev=/groups%3Fq%3DC%2523%2Bcompiler%2Bo
ptimize%2Bbug%2Bgroup:microsoft.public.dotnet.*%26hl%3Den%26lr%3D%26ie%3DUTF
-8%26selm%3DeySvl16JCHA.2240%2540tkmsftngp13%26rnum%3D1

Watch the line breaks!

Cheers,

Stoyan Damov


-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] Behalf Of Richard Blewett
Sent: 08/27/2003 19:35
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Nasty bug in 1.0 and 1.1 compiler


The code below executes both the if and the else in release build with
optimization turned on

<code>
    class DisposableClass : IDisposable
    {
        public void Dispose()
        {
        }
    }

    class Class1
    {
        static void Main(string[] args)
        {
            try
            {
                using ( new DisposableClass() )
                {
                    try
                    {
                        if ( args.Length == 0 )
                        {
                            Console.WriteLine("IN THE IF");
                            using ( new DisposableClass() )
                            {
                            }
                        }
                        else
                        {
                            Console.WriteLine("IN THE ELSE");
                            using ( new DisposableClass() )
                            {
                            }
                        }
                    }
                    catch ( Exception )
                    {
                    }
                }
            }
            catch ( Exception )
            {
            }

            Console.WriteLine("ending called");

        }
    }

</code>

commenting out the using block in the if block or putting code after the
using block in the if resolves the problem

Regards

Richard Blewett
DevelopMentor

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to