[Issue 7602] [CTFE] Segmentation fault when using array.keys on a null AA

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 18 22:30:28 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7602


hsteoh at quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh at quickfur.ath.cx


--- Comment #2 from hsteoh at quickfur.ath.cx 2012-03-18 22:30:42 PDT ---
OK, this is a very serious bug. Something is BADLY broken with CTFE:

struct AssociativeArray
{
    int *impl;
    int f()
    {
        if (impl !is null)
            auto x = *impl; // this is line 7
        return 1;
    }
}
void main() {
    int test()
    {
        AssociativeArray aa;
        return aa.f;
    }
    enum str = test();
}


This is not a fully minimized test case, but I've tried my best to reduce it as
much as possible. With the latest dmd from git, this gives:

test.d(7): Error: dereference of invalid pointer 'AssociativeArray(null)'
test.d(15):        called from here: aa.f()
test.d(17):        called from here: test()


This is a VERY serious bug because apparently the condition (impl !is null)
actually passes, even though impl is null!

This appears to be related to the current AssociativeArray magic (renaming the
struct in the above code makes the bug go away). I'm going to bump the severity
of this bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list