[Issue 796] Error: AssertError Failure internal\invariant.d(14)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 6 00:54:07 PST 2007


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





------- Comment #2 from lio at lunesu.com  2007-01-06 02:54 -------
Nice catch! I never would have thought of that.

In any case, the assertion failure / access violation can be easily fixed if
the compiler where to add a null-pointer check prior to checking the
invariants. Frankly, I think this makes sense too. We can expect many C/C++
people doing "assert(instance)" only to check the pointer. If it were to check
both the pointer and the invariants, that would just make it even more useful.

AFAIK, this cannot be changed by adding a check to invariant.d, since that
would add unnecessary overhead to all invariant checks. The code generation for
assert(instance) should be changed to include a pointer check: the assertion
should fail for null-pointers:

assert(classref) 
// =>
assert( (classref !is null) && _d_invariant(classref) );


-- 



More information about the Digitalmars-d-bugs mailing list