www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7917] New: --inline option fails for complex expressions

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7917

           Summary: --inline option fails for complex expressions
           Product: D
           Version: unspecified
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: russel winder.org.uk



PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 15 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7917


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc





 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 15 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7917




PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 16 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7917





 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 16 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7917




PDT ---
As far as I can see in the time available any further reduction loses the error
message.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 16 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7917





 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])); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 17 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7917




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)]);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 17 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7917


SomeDude <lovelydear mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear mailmetrash.com
           Platform|x86_64                      |All
         OS/Version|Linux                       |All



PDT ---
Also happens on 2.059 Win32

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7917


Denis <verylonglogin.reg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg gmail.com



---
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.


---
void f(alias fun)() { }

void g(T)() {
    void spam() {
        f!(a => a)();
    }
}

void main() {
    g!int();
    g!long();
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 03 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7917


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |WORKSFORME



18:06:03 PDT ---
This compiles without error in 2.064 head.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 03 2013