Bug 7917 – [ICE] (toir.c 178) with nested function

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-15T08:45:00Z
Last change time
2013-10-03T18:06:03Z
Keywords
ice
Assigned to
nobody
Creator
russel

Comments

Comment #0 by russel — 2012-04-15T08:45:43Z
Ignoring all issues of whether the code is good code or even idiomatic code, I am getting compilation problem with using --inline on complex expressions. So, for example, http://www.russel.org.uk/Bazaar/Pi_Quadrature/pi_d2_parallelMapSequentialReduce.d works fine without --inline but with it fails with: pi_d2_parallelMapSequentialReduce.d(32): Error: function std.parallelism.TaskPool.amap!(partialSum).amap!(Result).amap cannot get frame pointer to execute However, perhaps more problematic is that http://www.russel.org.uk/Bazaar/Pi_Quadrature/pi_d2_sequentialMap.d http://www.russel.org.uk/Bazaar/Pi_Quadrature/pi_d2_sequentialMapParallelReduce.d work fine without the --inline option but fail with it giving the error: Internal error: toir.c 178 It is not clear whether this latter is at all related to the former.
Comment #1 by bearophile_hugs — 2012-04-15T15:19:26Z
(In reply to comment #0) > However, perhaps more problematic is that > http://www.russel.org.uk/Bazaar/Pi_Quadrature/pi_d2_sequentialMap.d > http://www.russel.org.uk/Bazaar/Pi_Quadrature/pi_d2_sequentialMapParallelReduce.d > work fine without the --inline option but fail with it giving the error: > > Internal error: toir.c 178 I suggest you to minimize that program to the minimal program that shows the same error, and show it here.
Comment #2 by russel — 2012-04-16T04:41:09Z
Given the code: import std.algorithm ; import std.range ; import std.stdio ; import std.typecons ; double partialSum ( immutable Tuple ! ( int , int , double ) data ) { return 1.0 ; } void execute ( immutable int numberOfTasks ) { immutable n = 1000000000 ; immutable delta = 1.0 / n ; immutable sliceSize = n / numberOfTasks ; immutable pi = reduce ! ( ( a , b ) => a + b ) ( 0.0 , map ! ( partialSum ) ( map ! ( i => tuple ( i , cast ( int ) sliceSize , cast ( double ) delta ) ) ( iota ( numberOfTasks ) ) ) ) ; } int main ( immutable string[] args ) { execute ( 1 ) ; return 0 ; } The problem lies with the cast of sliceSice. Change the parameter to a literal and it goes away. Change the definition of sliceSize and it goes away.
Comment #3 by bearophile_hugs — 2012-04-16T04:56:08Z
(In reply to comment #2) > import std.algorithm ; > import std.range ; > import std.stdio ; > import std.typecons ; > > double partialSum ( immutable Tuple ! ( int , int , double ) data ) { > return 1.0 ; > } > > void execute ( immutable int numberOfTasks ) { > immutable n = 1000000000 ; > immutable delta = 1.0 / n ; > immutable sliceSize = n / numberOfTasks ; > immutable pi = reduce ! ( ( a , b ) => a + b ) ( 0.0 , map ! ( partialSum ) ( > map ! ( i => tuple ( i , cast ( int ) sliceSize , cast ( double ) delta ) ) > ( iota ( numberOfTasks ) ) ) ) ; > } > > int main ( immutable string[] args ) { > execute ( 1 ) ; > return 0 ; > } Maybe you are able to trim away some more stuff from that code, to minimize it some more.
Comment #4 by russel — 2012-04-16T05:08:36Z
As far as I can see in the time available any further reduction loses the error message.
Comment #5 by bearophile_hugs — 2012-04-17T11:15:02Z
(In reply to comment #4) > As far as I can see in the time available any further reduction loses the error > message. A first reduction: import std.algorithm: map; import std.typecons: tuple, Tuple; int foo(Tuple!(int)) { return 1; } void main() { int x = 2; map!foo(map!(_ => tuple(x))([3])); }
Comment #6 by bearophile_hugs — 2012-04-17T11:37:14Z
I am hitting the same "Internal error: toir.c 178" even without -inline with this reduced code: import std.algorithm: sort; struct Foo(int m) { int x; } void bar(int m)(Foo!m[] foos) { void spam() { //sort!((Foo!m a, Foo!m b) => true)(foos); // no error sort!((a, b) => true)(foos); } } void main() { alias Foo!2 F2; bar([F2(1)]); alias Foo!3 F3; bar([F3(2)]); }
Comment #7 by lovelydear — 2012-04-21T12:31:03Z
Also happens on 2.059 Win32
Comment #8 by verylonglogin.reg — 2012-05-03T03:25:30Z
This issue is derived from Issue 7955. Everything you need to create this issue from Issue 7955 is to wrap lambda template in a nested function. Code from Issue 7955 comment #1 with addition of `spam`: --- void f(alias fun)() { } void g(T)() { void spam() { f!(a => a)(); } } void main() { g!int(); g!long(); } ---
Comment #9 by bugzilla — 2013-10-03T18:06:03Z
This compiles without error in 2.064 head.