Thread overview
[Issue 858] New: Forward reference to struct inside class crashes the compiler
Jan 19, 2007
d-bugmail
Feb 23, 2007
d-bugmail
Nov 04, 2008
d-bugmail
Nov 04, 2008
d-bugmail
May 14, 2009
Don
January 19, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=858

           Summary: Forward reference to struct inside class crashes the
                    compiler
           Product: D
           Version: 1.00
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: georg.ramme@gmail.com


E:\prog\>dmd dontwork.d
---
The instruction as "0x004565b9" referenced memory at "0x00000038". The memory could not be "read".
---

E:\prog\>dmd work.d
E:\apps\dm\bin\link.exe work,,,user32+kernel32/noi;


/** dontwork.d **/
class Outer
{
  public:
    this()
    {
        B sc = new B();
    }

    class B
    {
        Strct str;
    }
}

struct Strct
{
    int i;
}


int main(char[][] args)
{
    return 0;
}


/** work.d **/
struct Strct
{
    int i;
}

class Outer
{
  public:
    this()
    {
        B sc = new B();
    }

    class B
    {
        Strct str;
    }
}

int main(char[][] args)
{
    return 0;
}

***


-- 

February 23, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=858





------- Comment #1 from thomas-dloop@kuehne.cn  2007-02-23 16:43 -------
Added to DStress as http://dstress.kuehne.cn/run/f/forward_reference_17_A.d http://dstress.kuehne.cn/run/f/forward_reference_17_B.d


-- 

November 04, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=858





------- Comment #2 from kamm-removethis@incasoftware.de  2008-11-04 05:04 -------
The code generation seems to crash because the vthis member of Inner's ClassDeclaration is NULL.

This happens when semantic is called again from runDeferredSemantic: first vthis is set to baseClass->vthis (baseClass is Object and vthis there is NULL) and then the interface and nested code isn't run again to correct it because sizeok != 0.


-- 

November 04, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=858





------- Comment #3 from kamm-removethis@incasoftware.de  2008-11-04 05:10 -------
I looked at the code in dstress, not the one posted here. The Inner in my description is georg's inner B class.


-- 

May 14, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=858


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |FIXED




--- Comment #4 from Don <clugdbug@yahoo.com.au>  2009-05-14 05:04:02 PDT ---
No longer segfaults in DMD2.040 and 1.030. Still doesn't compile (generates a
forward reference error).
However, the original bug is fixed.
TEST CASE:
---
class A{
    class B {
        S s;
    }
    void foo() {
        B b = new B();
    }
}
struct S {}
---
ice.d(6): Error: forward reference to B

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