Bug 4504 – D1: ICE(toir.c) nested function passed by alias to nested member function
Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2010-07-25T04:44:00Z
Last change time
2013-11-24T19:42:55Z
Keywords
ice
Assigned to
nobody
Creator
peter.alexander.au
Comments
Comment #0 by peter.alexander.au — 2010-07-25T04:44:05Z
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.
Comment #1 by bearophile_hugs — 2010-07-25T04:49:55Z
On Windows, dmd 2.047, I don't see the error.
Comment #2 by peter.alexander.au — 2010-07-25T04:52:25Z
(In reply to comment #1)
> On Windows, dmd 2.047, I don't see the error.
Interesting. Did you compile with -inline?
Comment #3 by bearophile_hugs — 2010-07-25T05:40:21Z
I'm using just basic compilation:
dmd test.d
Comment #4 by peter.alexander.au — 2010-07-25T05:53:59Z
(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)"
Comment #5 by clugdbug — 2010-11-22T02:02:04Z
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;
}
Comment #6 by clugdbug — 2010-11-22T02:07:10Z
The reduced case shows it doesn't require -inline.
Comment #7 by clugdbug — 2010-11-22T02:12:16Z
*** Issue 4784 has been marked as a duplicate of this issue. ***
Comment #8 by braddr — 2011-02-06T15:40:12Z
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.
Comment #9 by clugdbug — 2011-10-25T02:49:48Z
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;
}
Comment #10 by bearophile_hugs — 2012-01-26T04:54:36Z
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;
}
}
Comment #11 by bearophile_hugs — 2012-01-26T04:56:11Z
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
Comment #12 by bugzilla — 2012-03-12T20:40:24Z
With 2.059, no error occurs for the original case.
The errors in the other cases are legitimate, and are different.
Comment #13 by clugdbug — 2012-05-03T04:49:17Z
The ICE still happens on D1.074 and D1 git head.
Reopening and marking as D1 only.