[Mono-devel-list] FW: [ADVANCED-DOTNET] Nasty bug in 1.0 and 1.1 compiler

Chris Day ChrisD at monkey.biz
Thu Aug 28 02:40:54 EDT 2003


Maybe something to look out for?

-----Original Message-----
From: Richard Blewett [mailto:richardb at DEVELOP.COM] 
Sent: Thursday, 28 August 2003 2:35 AM
To: ADVANCED-DOTNET at DISCUSS.DEVELOP.COM
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(r)  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



More information about the Mono-devel-list mailing list