Huh, this is really strange. Moving the cartesianProduct line inside main() makes the problem go away. Why?
Comment #3 by hsteoh — 2013-05-27T21:19:14Z
Hmph. I think this is a compiler bug. Putting the code inside a unittest block makes the problem go away too.
Comment #4 by hsteoh — 2013-05-27T21:40:27Z
Retitled this bug based on bearophile's reduction, and comparison of the disassembly of buggy version (result assigned to module-global variable) vs. non-buggy version (result assigned to local variable); this looks like a wrong-code bug.
Comment #5 by maxim — 2013-05-27T22:03:00Z
Simplified:
struct MapResult(alias fun) {
@property auto ref front() {
return fun(1);
}
}
auto map(alias fun)() {
return MapResult!(fun)();
}
auto foo(int[] r) {
return map!((int x) => r)();
}
auto result = foo([1]);
void main() {
result.front();
}
There is wrong-code on accessing or passing module object. It has nothing to do with auto or ranges.
Comment #6 by dlang-bugzilla — 2017-07-05T14:53:33Z
(In reply to Dicebot from comment #0)
> Motivating code snippet:
BTW, this example works since https://github.com/dlang/phobos/pull/2534. The reductions in comment 1 and comment 5 still produce a segfaulting program.
Comment #7 by robert.schadek — 2024-12-13T18:05:26Z