www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5238] New: PATCH: fix return of uninitialised var in interpret.c

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

           Summary: PATCH: fix return of uninitialised var in interpret.c
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: s.d.hammett googlemail.com


--- Comment #0 from simon <s.d.hammett googlemail.com> 2010-11-18 16:17:58 PST
---
Created an attachment (id=820)
PATCH: fix return of uninitialised var in interpret.c

As summary:
triggered by test/runnable/interpret.d, line 2034

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


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
    Attachment #820|application/octet-stream    |text/plain
          mime type|                            |
 Attachment #820 is|0                           |1
              patch|                            |


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


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr puremagic.com


--- Comment #1 from Brad Roberts <braddr puremagic.com> 2010-11-18 21:15:05 PST
---
With this patch applied on my system, I still fail to pass runnable/interpret.d
with -O, but now a few lines later at 2110:

2106 int goodfoo3()
2107 {
2108    S[4] w = void; // uninitialized array of structs
2109    w[$-2].x = 217; // initialize one member
2110    return w[2].x;
2111 }
2112 static assert(goodfoo3()==217);

Simon, did you find this due to a failure with no changes to interpret.d or
with -O added to the set of compilation flags to test?

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



--- Comment #2 from Brad Roberts <braddr puremagic.com> 2010-11-18 21:24:56 PST
---
changing 2109 below to just w[2] rather than w[$-2] (same array index) makes
that problem go away.  And with that change, the entire test passes, which is
great.  Just leaves one bug to find. :)

Oh, and the error is:
runnable/interpret.d(2110): Error: variable w used before set

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



--- Comment #3 from Brad Roberts <braddr puremagic.com> 2010-11-18 22:15:48 PST
---
Created an attachment (id=821)
changes to runnable/interpret.d

The problem is with the optimizer, not ctfe.  Switching to this form, so that
there's no code for the optimizer to chew on and complain about works:

static assert(is(typeof(Compileable!(
(){
   S[4] w = void; // uninitialized array of structs
   w[$-2].x = 217; // initialize one member
   return w[2].x;
}()).OK
)));

I'll file a separate bug report for that.

Adding a patch for runnable/interpret.d to be applied in addition to simon's
changes.

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



--- Comment #4 from simon <s.d.hammett googlemail.com> 2010-11-19 06:21:24 PST
---
(In reply to comment #1)
 With this patch applied on my system, I still fail to pass runnable/interpret.d
 with -O, but now a few lines later at 2110:
 
 2106 int goodfoo3()
 2107 {
 2108    S[4] w = void; // uninitialized array of structs
 2109    w[$-2].x = 217; // initialize one member
 2110    return w[2].x;
 2111 }
 2112 static assert(goodfoo3()==217);
 
 Simon, did you find this due to a failure with no changes to interpret.d or
 with -O added to the set of compilation flags to test?
Neither. I've build DMD with Visual studio; the vc compiler does a pretty good job of detected these sorts of bugs in debug builds. I'll run the rest of the tests when I get home, see if there are any other gotchas lurking. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5238


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2010-12-07
15:20:17 PST ---
http://www.dsource.org/projects/dmd/changeset/791

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


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #6 from Walter Bright <bugzilla digitalmars.com> 2010-12-08
17:35:55 PST ---
Marking this as fixed since it passes the test suite, including the revised
interpret.d

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