Acces Violation: assert with null instance
Lionello Lunesu
lio at lunesu.remove.com
Wed Jan 10 23:07:12 PST 2007
Stewart Gordon wrote:
> Frits van Bommel wrote:
>> 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.
>
> What is the Bugzilla issue number? I can't seem to find it.
796
>> 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...
>
> "The invariant can be checked when a class object is the argument to an
> assert() expression, as:"
>
> I see this as giving an _additional_ use of assert, something that
> assert on a class object may do as an extra. The general contract of
> assert is supposed to remain, and the fact that out of the box it
> doesn't certainly constitutes a bug, at least IMO.
I agree, that why I filed that bug :)
L.
More information about the Digitalmars-d-bugs
mailing list