Bug 12202 – SortedRange + alias this + foreach => Segmentation fault

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-19T05:27:00Z
Last change time
2017-01-09T17:40:08Z
Keywords
ice
Assigned to
nobody
Creator
tobias

Comments

Comment #0 by tobias — 2014-02-19T05:27:07Z
-- struct S(T) 4 { 5 import std.range; 6 7 T[] data; 8 9 auto sortedRange() { return assumeSorted(data); } 10 alias sortedRange this; 11 12 } 13 unittest 14 { 15 auto a1 = S!int([1, 3,3,3, 4, 4]); 16 foreach(i, e; a1) 17 { 18 19 } 20 } -- $ dmd -unittest -main test.d zsh: segmentation fault (core dumped) dmd -unittest -main test.d Both in 2.064 and ~master.
Comment #1 by hsteoh — 2014-09-11T19:30:59Z
Reduced test case: ------ struct S(T) { import std.range; } unittest { auto a1 = S!int(); foreach(i, e; a1) { } } ------ Seems this has nothing to do with sortedRange, it's a compiler bug.
Comment #2 by hsteoh — 2014-09-11T20:54:26Z
OK, managed to cut it down to an almost bare-minimal test case: ----range.d---- @property front()() { } --------------- ----test.d---- struct S { import range; } unittest { S a1; foreach(i, e; a1) { } } --------------- Compiler command: dmd -main -unittest test.d
Comment #3 by mk — 2017-01-09T17:40:08Z
All examples produce an error message since 2.071