www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4036] New: Segfault with -inline and literal of struct containing union

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4036

           Summary: Segfault with -inline and literal of struct containing
                    union
           Product: D
           Version: 1.057
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: matti.niemenmaa+dbugzilla iki.fi


--- Comment #0 from Matti Niemenmaa <matti.niemenmaa+dbugzilla iki.fi>
2010-04-01 05:34:25 PDT ---
struct XY { union { int x, y; } }
struct AHolder {
    XY aa;
    void a(XY x) { aa = x; }
}
struct AB {
    AHolder aHolder;
    XY b;
    void a(XY x) { aHolder.a(x); }
}
struct Main {
    AB ab;

    void setB() { ab.b = XY(); }
    void f() {
        ab.a(XY.init);
        setB();
    }
}

$ dmd -c -inline arst.d
Segmentation fault

Any of the following semantics-preserving changes will fix it:

- Making Main.setB use XY.init instead of XY()
- Inlining ab.a(XY.init) into Main.f
- Inlining setB() into Main.f
- Inlining aHolder.a(x) into AB.a

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 01 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4036


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |clugdbug yahoo.com.au


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-04-08 23:55:12 PDT ---
PATCH: Uninitialized variable causing memory corruption.

bug 4036. inline.c, arrayExpressiondoInline(), line 460.
---------
            if (e)
            {
                e = e->doInline(ids);
                newa->data[i] = (void *)e;
            }
+            else
+                newa->data[i] = 0;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 08 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4036


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Don <clugdbug yahoo.com.au> 2010-05-05 19:08:32 PDT ---
Fixed DMD2.044

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