Acces Violation: assert with null instance

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed Jan 10 14:18:24 PST 2007


Stewart Gordon wrote:
> For some strange reason, assert on an object reference checks that the 
> invariants are satisfied instead of that the reference isn't null. 
> There's nothing to this effect in the spec, so I don't know how it came 
> about.  While it may be useful, it certainly shouldn't do it _instead 
> of_ checking it isn't null.

As I commented recently when this bug was added to bugzilla, it's in the 
spec. It's just not where you'd expect it.
It's noted at http://www.digitalmars.com/d/class.html#invariants (the 
section on class invariants) instead of in the section on asserts.
I've since added a warning about this on the comments page for the page 
containing the section on asserts.

Also, the null check *is* in the code, but when Phobos is compiled in 
release mode (which the pre-compiled version is) the assert isn't 
performed...


More information about the Digitalmars-d-bugs mailing list