www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3575] New: CTFE: member structs not initialized correctly

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

           Summary: CTFE: member structs not initialized correctly
           Product: D
           Version: 1.051
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: patch, rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au


--- Comment #0 from Don <clugdbug yahoo.com.au> 2009-12-05 01:54:25 PST ---
This is a couple of cases I missed in my CTFE patches in DMD2.032.
Root cause: defaultInit for a struct is a VarExp, not a StructLiteral. This
needs to be applied recursively. Patch: I've added a recursive
defaultInitAsStructLiteral() to TypeStruct. It needs to be called from two
places in interpret.c.

---------------------------------
struct SwineFlu {
   int a; int b;
}

struct Infection {
    SwineFlu y;
}

struct IveGotSwineFlu {
   Infection x;
   int z;
   int oink() { return x.y.a+10; }   
}

int quarantine() {
   IveGotSwineFlu d;
   return d.oink();
}

struct Mexico {
  Infection x;
  int z=2;
  int oink() { return z+x.y.b; }
}

int mediafrenzy() {
  Mexico m;
  return m.oink;
}

static assert( quarantine() == 10);
static assert( mediafrenzy() == 2);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 05 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3575



--- Comment #1 from Don <clugdbug yahoo.com.au> 2009-12-05 01:56:24 PST ---
Created an attachment (id=522)
Patch against DMD2.037 svn 283.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 05 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3575


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2009-12-30
00:11:37 PST ---
Changeset 321

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 30 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3575


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2009-12-31
11:12:24 PST ---
Fixed dmd 1.054 and 2.038

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