D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5902 - ICE(toir.c) when there is a cross-module call to a closure
Summary: ICE(toir.c) when there is a cross-module call to a closure
Status: RESOLVED DUPLICATE of issue 8704
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: ice
Depends on:
Blocks:
 
Reported: 2011-04-27 12:33 UTC by kennytm
Modified: 2014-04-11 12:18 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kennytm 2011-04-27 12:33:17 UTC
Test case:

--------------------
// x.d:
import y;
struct A(alias f) {
    void front() {
        f();
    }
}
void main() {
    int sectid;
    void g(){ cast(void) sectid; }  // access a local variable (make a closure)
    s!(A!g);
}
--------------------
// y.d:
void s(ROR)() {
    void r() {
        ROR().front();
    }
}
--------------------
$ dmd -inline x
Internal error: toir.c 190
--------------------

* If '-inline' is removed, the bug is gone.
* If I suppress output by providing the '-o-' flag, the bug is gone.
* If the function 's()' is moved into 'x.d', the bug is gone.
* If the 'ROR().front()' call is not placed inside the function 'r', the ICE is gone, and the error becomes

-----------------------
y.d(3): Error: function D main is a nested function and cannot be accessed from s
x.d(11): Error: function D main is a nested function and cannot be accessed from s
-----------------------

Maybe the same as issue 4504 or issue 5499, which also relates to function delegates.

(I don't know if it is valid code or not, so I put both ice-on keywords :) )
Comment 1 kennytm 2011-04-27 12:35:48 UTC
Correction: -inline is *not* required.

----------------------------
$ dmd x
Internal error: toir.c 190
----------------------------
Comment 2 SomeDude 2012-04-20 10:27:18 UTC
Fails also on Win32 2.059
Comment 3 Kenji Hara 2014-04-11 12:18:35 UTC
(In reply to kennytm from comment #0)
> Test case:
> 
> --------------------
> // x.d:
> import y;
> struct A(alias f) {
>     void front() {
>         f();
>     }
> }
> void main() {
>     int sectid;
>     void g(){ cast(void) sectid; }  // access a local variable (make a
> closure)
>     s!(A!g);
> }
> --------------------
> // y.d:
> void s(ROR)() {
>     void r() {
>         ROR().front();
>     }
> }

By fixing issue 8704, ROR() in y.d will produce "cannot access frame pointer of x.main" error from front-end layer. Then the glue-layer error will be fixed.

*** This issue has been marked as a duplicate of issue 8704 ***