Bug 14987 – Internal error: backend/cod1.c 1711

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-08-31T12:11:00Z
Last change time
2015-10-03T01:59:19Z
Keywords
ice
Assigned to
nobody
Creator
rswhite4

Comments

Comment #0 by rswhite4 — 2015-08-31T12:11:48Z
Code: ---- import std.range : repeat, take; pragma(inline, true); auto s(T, size_t dim)(auto ref T[dim] result) { return result; } pragma(inline, true); auto dim(size_t dim) { return [dim.repeat.take(4)].s; } void main() { auto arr2 = dim(4); } ---- Tried on Dpaste with 2.068
Comment #1 by luis — 2015-08-31T16:51:04Z
rswhite4, although the compiler error should be fixed, I don't think this code was going to work anyway. size_t[4] and size_t[5] are different types, and `auto dim(size_t dim);` is not a template, so you would not be able to return one or the other from the same function. Did you mean to write something like this? import std.range : repeat, take, array; auto dim(size_t n)() { size_t[n] a = n.repeat.take(n).array; return a; } void main() { auto arr1 = dim!4; }
Comment #2 by rswhite4 — 2015-08-31T19:16:20Z
(In reply to Luís Marques from comment #1) > rswhite4, although the compiler error should be fixed, I don't think this > code was going to work anyway. size_t[4] and size_t[5] are different types, > and `auto dim(size_t dim);` is not a template, so you would not be able to > return one or the other from the same function. > > Did you mean to write something like this? > > import std.range : repeat, take, array; > > auto dim(size_t n)() > { > size_t[n] a = n.repeat.take(n).array; > return a; > } > > void main() > { > auto arr1 = dim!4; > } Nope, just testing.
Comment #3 by dlang-bugzilla — 2015-09-01T12:10:27Z
Comment #4 by k.hara.pg — 2015-09-01T13:05:46Z
In my local Windows environment, both of -m32 and -m64 didn't cause backend ICE.
Comment #5 by dlang-bugzilla — 2015-09-01T13:07:31Z
Mine too, forgot to mention that. It is strange. But I reproduced it on Linux.
Comment #6 by bugzilla — 2015-10-03T01:59:19Z
*** This issue has been marked as a duplicate of issue 14782 ***