Bug 12982 – internal error when using array expression as an argument

Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2014-06-24T13:43:00Z
Last change time
2014-06-24T21:42:40Z
Assigned to
nobody
Creator
peterj

Attachments

IDFilenameSummaryContent-TypeSize
1364test_array_expr.dsample source filetext/x-dsrc847

Comments

Comment #0 by peterj — 2014-06-24T13:43:23Z
Created attachment 1364 sample source file The DMD 2.065 compiler fails with internal error when I try to pass the result of an array expression as a function argument. There is no problem when I assign the result to an array and then pass a reference to that array. See the attached source file for the transcript.
Comment #1 by bearophile_hugs — 2014-06-24T14:09:15Z
D vector ops are designed to never allocate memory. An operation like 2.0*a[] doesn't mutate the array 'a', so there's nowhere for the result to go. So this is not a bug, and I think this issue should be closed as invalid.
Comment #2 by bearophile_hugs — 2014-06-24T14:22:36Z
This code: double[] f1(double[] x) { double[] result = x.dup; result[] = x[] * 3.0; return result; } void main() { import std.stdio; double[] a = [1.0, 2.0]; writeln("a= ", a); double[] b = f1(2.0 * a[]); writeln("b= ", b); } I am not seeing a internal compiler error: test.d(11): Error: array operation a[] * 2.00000 without assignment not implemented But I agree the error message should be improved. So if you want we can turn this issue in a diagnostic enhancement request.
Comment #3 by k.hara.pg — 2014-06-24T15:34:51Z
(In reply to bearophile_hugs from comment #2) > I am not seeing a internal compiler error: > > test.d(11): Error: array operation a[] * 2.00000 without assignment not > implemented This is a dup of issue 12179, and the ICE is fixed in git-head. *** This issue has been marked as a duplicate of issue 12179 ***
Comment #4 by bearophile_hugs — 2014-06-24T15:43:20Z
(In reply to Kenji Hara from comment #3) > This is a dup of issue 12179, and the ICE is fixed in git-head. > > *** This issue has been marked as a duplicate of issue 12179 *** An error message like "assignment not implemented" is worth a little diagnostic enhancement request.
Comment #5 by peterj — 2014-06-24T21:42:40Z
(In reply to bearophile_hugs from comment #4) > (In reply to Kenji Hara from comment #3) > > > This is a dup of issue 12179, and the ICE is fixed in git-head. > > > > *** This issue has been marked as a duplicate of issue 12179 *** > > An error message like "assignment not implemented" is worth a little > diagnostic enhancement request. The error message in comment 2 is clear enough. Thank you.