Thread overview
[Issue 6733] New: DMD Crash (internal error)
[Issue 6733] Regression(2.054) ICE(cod2.c) struct literals as template arguments
Oct 21, 2011
Don
Oct 21, 2011
Brad Roberts
Oct 21, 2011
Don
Oct 21, 2011
Don
Oct 21, 2011
Don
[Issue 6733] Regression(2.054) ICE(cod2.c) pure nothrow func with side-effect parameters
Oct 22, 2011
Walter Bright
September 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6733

           Summary: DMD Crash (internal error)
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: wfunction@hotmail.com


--- Comment #0 from wfunction@hotmail.com 2011-09-26 10:30:20 PDT ---
I have no idea what the heck is going on, but this crashes on DMD32 D Compiler v2.055:

struct Zero { }
void test(T1, T2)(T1 a, T2 b) { }
void main() { test(Zero(), Zero()); }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6733



--- Comment #1 from wfunction@hotmail.com 2011-09-26 10:30:56 PDT ---
Oh, and the error is:

Internal error: ..\ztc\cod2.c 4624

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6733


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |clugdbug@yahoo.com.au
            Summary|DMD Crash (internal error)  |Regression(2.054)
                   |                            |ICE(cod2.c) struct literals
                   |                            |as template arguments
           Severity|critical                    |regression


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-10-21 00:03:39 PDT ---
This worked in 2.053 and earlier.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6733


Brad Roberts <braddr@puremagic.com> changed:

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


--- Comment #3 from Brad Roberts <braddr@puremagic.com> 2011-10-21 00:44:05 PDT ---
I just bisected it down to:

commit 4c9661fa9fbd427909a334133dfc7f3869e47c31
Author: Walter Bright <walter@walterbright.com>
Date:   Thu Jun 23 00:50:46 2011 -0700

    nothrow inference

Reverting it from tip of master yields a successful build of the code above.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6733



--- Comment #4 from Don <clugdbug@yahoo.com.au> 2011-10-21 01:04:13 PDT ---
(In reply to comment #3)
> I just bisected it down to:
> 
> commit 4c9661fa9fbd427909a334133dfc7f3869e47c31
> Author: Walter Bright <walter@walterbright.com>
> Date:   Thu Jun 23 00:50:46 2011 -0700
> 
>     nothrow inference
> 
> Reverting it from tip of master yields a successful build of the code above.

Thanks. The backend failure is occuring inside a comma expression (x, y). Fails
because x isn't an expression, it's just a parameter (presumably the struct
literal).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6733



--- Comment #5 from Don <clugdbug@yahoo.com.au> 2011-10-21 01:19:10 PDT ---
Actually this is more a pseudo-regresssion, it's just an expansion of an existing bug into a few more cases. Walter's commit has nothing to do with the root cause. The test case below fails in exactly the same way on 2.025 (but passed on 2.023).

struct Zero { int x; }
void test(T)(T a, T b) pure nothrow { }
void main() { test(Zero(7), Zero(4)); }

The bug is triggered when test() gets completely optimized away because it's
pure nothrow.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6733



--- Comment #6 from Don <clugdbug@yahoo.com.au> 2011-10-21 05:05:58 PDT ---
Reduced test case:

void bug6733(int a, int b) pure nothrow { }
void main() {
   int z;
   bug6733(z++, z++);
}

This is definitely a backend bug. What happens is, that since it's pure nothrow
and the result is unused, it's a no-side-effect call (OPcallns).
In the first optimisation step (optelem in cgelem.c), the call gets discarded,
and simply replaced with the parameter list (wrapped in an OPparam). If the
parameters had no side-effects, the whole thing would be discarded.
If there's only one with a side-effect, it's the only thing that's left. But if
there are TWO with side-effects, the OPparam remains.
The rest of the backend can't cope with a naked OPparam. Boom.
Solution would be to replace the OPparam with comma expressions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 22, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6733


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #7 from Walter Bright <bugzilla@digitalmars.com> 2011-10-22 02:53:28 PDT ---
https://github.com/D-Programming-Language/dmd/commit/6536012f7e23d5dc5928567224d47cc7d9997ceb

https://github.com/D-Programming-Language/dmd/commit/ab50833d7ca7fde0380525ed11e66908c440667a

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