6733 – Regression(2.054) ICE(cod2.c) pure nothrow func with side-effect parameters

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6733 - Regression(2.054) ICE(cod2.c) pure nothrow func with side-effect parameters
Summary: Regression(2.054) ICE(cod2.c) pure nothrow func with side-effect parameters
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 regression
Assignee: No Owner
URL:
Keywords: ice-on-valid-code
: 6890 (view as issue list)
Depends on:
Blocks:
Reported: 2011年09月26日 10:30 UTC by dlang+issues
Modified: 2011年12月08日 00:57 UTC (History)
4 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description dlang+issues 2011年09月26日 10:30:20 UTC
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()); }
Comment 1 dlang+issues 2011年09月26日 10:30:56 UTC
Oh, and the error is:
Internal error: ..\ztc\cod2.c 4624
Comment 2 Don 2011年10月21日 00:03:39 UTC
This worked in 2.053 and earlier.
Comment 3 Brad Roberts 2011年10月21日 00:44:05 UTC
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.
Comment 4 Don 2011年10月21日 01:04:13 UTC
(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).
Comment 5 Don 2011年10月21日 01:19:10 UTC
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.
Comment 6 Don 2011年10月21日 05:05:58 UTC
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.
Comment 8 Don 2011年12月08日 00:57:29 UTC
*** Issue 6890 has been marked as a duplicate of this issue. ***


AltStyle によって変換されたページ (->オリジナル) /