Acces Violation: assert with null instance
Sean Kelly
sean at f4.ca
Wed Jan 24 15:19:46 PST 2007
Walter Bright wrote:
> 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.
But that's generated by the hardware, isn't it? Shouldn't assert
explicitly check whether c is null before calling its invariant?
Sean
More information about the Digitalmars-d-bugs
mailing list