Empty associative array crashes program
Steven Schveighoffer
schveiguy at yahoo.com
Tue Apr 2 06:52:37 PDT 2013
On Tue, 02 Apr 2013 01:22:26 -0400, Maxim Fomin <maxim at maxim-fomin.ru>
wrote:
> On Monday, 1 April 2013 at 23:56:08 UTC, Steven Schveighoffer wrote:
>> No, AA's are not classes (which BTW have had that problem fixed), they
>> are pImpl structs. The equals operator should check for null before
>> comparing the contents. It is a valid bug.
>>
>> -Steve
>
> This argument can be applied to classes too. I think it would be better
> to reject such code like in case with classes.
If you are saying you think AA's should reject the code when comparing to
null, then I don't agree. An AA is a struct, and a struct lives on the
stack. It would be near impossible to make this work without arbitrary
compiler help, and I don't see a reason to specifically add this. It's
just as easy to check for null in opEquals.
With classes there was NO way to intercept the comparison before the
dereference, so the banning of == null was warranted (that situation has
changed now that opEquals is a global runtime function, so this
requirement is somewhat moot).
-Steve
More information about the Digitalmars-d
mailing list