Compiling the following produces the error at compile time: "Internal error: toir.c 190" import std.algorithm; import std.range; void main() { int foo(int i) { return i == 1 ? 1 : foo(1); } auto x = count(map!foo(iota(1, 2)), 1); } Only happens when: - foo is recursive - foo is a local function (doesn't happen if it is global) - when using count (calling the function alone, or just mapping is fine) - when compiling with (-inline) If any one of these conditions isn't met then the code compiles as expected. Note that while I have only noticed that std.algorithm.count causes this problem, and std.algorithm.map doesn't, I haven't tested any other algorithms. I'm using DMD 2.047.
On Windows, dmd 2.047, I don't see the error.
(In reply to comment #1) > On Windows, dmd 2.047, I don't see the error. Interesting. Did you compile with -inline?
I'm using just basic compilation: dmd test.d
(In reply to comment #3) > I'm using just basic compilation: > dmd test.d Well you won't get the error :P "Only happens when: ... - when compiling with (-inline)"
Reduced test case, from the duplicate bug 4784. --- struct A( alias P ) { static void a() { void aa() { P(); } } } template B( alias P ) { void b() { A!P a; } } struct C( alias P ) { void c() { B!P.b(); } } void main() { void bar() {} C!bar c; }
The reduced case shows it doesn't require -inline.
*** Issue 4784 has been marked as a duplicate of this issue. ***
Mass migration of bugs marked as x86-64 to just x86. The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.
Reduced test case applies to D1 as well: struct B4504(alias P) { static void a() { void aa() { P(); } } } void bug4504() { void bar() {} B4504!(bar) b; }
Same bug? import std.algorithm: map; void foo() { map!(x => x)([1]); } void main() { int opApply(int delegate(ref int) dg) { int result; foo(); result = dg(result); if (result) return result; return result; } }
Same bug? import std.algorithm: map; void foo() { map!(x => x)([1]); } struct Bar { int opApply(int delegate(ref int) dg) { int result; foo(); result = dg(result); if (result) return result; return result; } } void main() {} DMD 2.058head: test.d(6): Error: function test.Bar.opApply cannot get frame pointer to map
With 2.059, no error occurs for the original case. The errors in the other cases are legitimate, and are different.
The ICE still happens on D1.074 and D1 git head. Reopening and marking as D1 only.
D1 is not supported anymore.