[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [DotGNU]Bug - null objects and stack traces.
From: |
Fergus Henderson |
Subject: |
Re: [DotGNU]Bug - null objects and stack traces. |
Date: |
Mon, 7 Oct 2002 01:19:06 +1000 |
User-agent: |
Mutt/1.3.28i |
On 06-Oct-2002, Gopal V <address@hidden> wrote:
> If memory serves me right, Rhys Weatherley wrote:
> > It is perfectly legitimate to call a method with a null "this"
> > object in CLI. Object references are checked at the point they
> > are first dereferenced. Dereferences occur when you access a
> > field or make a virtual method call (which needs to access the
> > vtable in the object). Because "Push" is not virtual, the first
> > time that "s" is dereferenced is within the method body. MS'es
> > CLR does the same thing.
>
> "call" instruction does not throw a NullReferenceException , but
> "callvirt" does ... But "why ?" is not something I can answer.
Two reasons:
- Efficiency. A typical implementation of "callvirt" will trap for
null references anyway, whereas a typical implementation of "call" won't.
- Support for other languages. The CLI should support languages whose
procedure calls don't trap when the "this" pointer (or equivalent) is null.
--
Fergus Henderson <address@hidden> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.