[Mono-list] Mono not catching this, VS does

Matt Calder mvcalder at gmail.com
Fri Nov 4 10:02:43 EDT 2011


I don't know whether to call this a bug, but this code can result in an
access of the List list, without assigning to it (in the case b is false):

        public static void Foo(bool b)
        {
            int i;
            List<int> list;
            if (b && !dict.TryGetValue("foo", out list)) {
                dict["foo"] = new List<int>();
            } else {
                i = list[0];
            }

        }

Visual studio flags this as a compiler error. I am using:

$ mono --version
Mono JIT compiler version 2.11 ((no/7917753 Wed Mar 30 15:47:09 EDT 2011)
Copyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug
    LLVM:          yes(2.8svn-mono)
    GC:            Included Boehm (with typed GC and Parallel Mark)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20111104/3fb883c3/attachment-0001.html 


More information about the Mono-list mailing list