Non-null objects, the Null Object pattern, and T.init

Jacob Carlborg doob at me.com
Sat Jan 18 02:28:12 PST 2014


On 2014-01-18 07:10, Walter Bright wrote:

> BTW, the following program:
>
>    class C { int a,b; }
>
>    int test() {
>      C c;
>      return c.b;
>    }
>
> When compiled with -O:
>
>    foo.d(6): Error: null dereference in function _D3foo4testFZi
>
> It isn't much, only working on intra-function analysis and only when the
> optimizer is used, but it's something. It's been in dmd for a long time.


Why only when the optimizer is used?

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list