www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4504] New: Internal compiler error using std.algorithm.count with recursive nested function in release.

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

           Summary: Internal compiler error using std.algorithm.count with
                    recursive nested function in release.
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: peter.alexander.au gmail.com



04:44:05 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 25 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4504


bearophile_hugs eml.cc changed:

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



On Windows, dmd 2.047, I don't see the error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 25 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4504




04:52:25 PDT ---

 On Windows, dmd 2.047, I don't see the error.
Interesting. Did you compile with -inline? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 25 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4504




I'm using just basic compilation:
dmd test.d

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 25 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4504




05:53:59 PDT ---

 I'm using just basic compilation:
 dmd test.d
Well you won't get the error :P "Only happens when: ... - when compiling with (-inline)" -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 25 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4504




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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4504


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE(toir.c) using           |ICE(toir.c) using
                   |std.algorithm.count with    |std.algorithm.count with
                   |recursive nested function   |recursive nested function
                   |and -inline.                |passed by alias



The reduced case shows it doesn't require -inline.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4504




*** Issue 4784 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4504


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|x86_64                      |x86



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4504


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D2                          |D1 & D2
            Summary|ICE(toir.c) using           |ICE(toir.c) nested function
                   |std.algorithm.count with    |passed by alias to nested
                   |recursive nested function   |member function
                   |passed by alias             |
         OS/Version|Mac OS X                    |All



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 25 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4504




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

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




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

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


Walter Bright <bugzilla digitalmars.com> changed:

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



20:40:24 PDT ---
With 2.059, no error occurs for the original case.

The errors in the other cases are legitimate, and are different.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
            Version|D1 & D2                     |D1
         Resolution|WORKSFORME                  |



The ICE still happens on D1.074 and D1 git head.

Reopening and marking as D1 only.

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