Acces Violation: assert with null instance

Walter Bright newshound at digitalmars.com
Wed Jan 24 15:02:52 PST 2007


Stewart Gordon wrote:
> Lionello Lunesu wrote:
>> I really think this used to work (like in C++) :
>>
>> #class Class {}
>> #void main(){
>> #    Class c;
>> #    assert(c);
>> #}
>>
>> With 1.0, I get an access violation in 
>> _D9invariant12_d_invariantFC6ObjectZv, but why?
> <snip>
> 
> 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.
> 
> Stewart.

It does check if it's null. That's how the access violation exception 
gets thrown.


More information about the Digitalmars-d-learn mailing list