[Issue 4595] Accessing non-static member of a null reference compiles

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 7 19:21:59 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4595


bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs at eml.cc


--- Comment #3 from bearophile_hugs at eml.cc 2010-08-07 19:21:57 PDT ---
You are mostly right nfxjfg, but please don't be harsh with people that use
their time to submit problems in Bugzilla :-)

See enhancement request bug 4571 for a start of a proposal about non-null types
modifier in D. It needs more work, of course.

And even if D will never have non-null references in its type system, DMD is
already able to catch cases like this, if you compile it with -O:

class Foo { int x; }
void main() {
    Foo f;
    f.x = 5;
}


dmd 2.047 doesn't show a run-time sefault, it prints at compile-time:
test.d(4): Error: null dereference in function _Dmain

So adding few more logic to the compiler to catch other common cases of
uninitialized bugs is not inconceivable. The case shown in this bug reports are
well within the capabilities of a short analysis, good lint tools are able to
warn against far more complex cases. So I think this enhancement request should
be reopened.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list