Empty associative array crashes program

"Luís "Luís
Mon Apr 1 13:32:01 PDT 2013


I added a bug to the database, because the following code results 
in a segfault (DMD v2.062, OS X 10.8.3, 64-bit):

     #!/usr/local/bin/rdmd

     @safe:

     void main()
     {
         int[string] a;
         a["foo"] = 0;
         a.remove("foo");
         assert(a != null); // segfault (not exception)
     }

Now I come here for some further clarifications. While it seems 
fairly clear to me that the assert should not crash the program 
with a segmentation fault (at least with @safe), is the assert 
actually true? (Is it even specified by the language if the AA 
can become null again, after removing the last item?)

Second, I didn't test this in other OSes, but assuming the bug is 
reproducible, am I actually the first one to trip on this issue? 
It seems too basic, but I didn't find a duplicate in the bug 
database.

Best regards,
Luís


More information about the Digitalmars-d mailing list