Bug 13415 – [REG2.066] '-inline' causes wrong enclosing scope pointer for nested function called from templated struct
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-09-01T18:56:00Z
Last change time
2014-09-04T13:50:56Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
verylonglogin.reg
Comments
Comment #0 by verylonglogin.reg — 2014-09-01T18:56:22Z
This code should run fine:
a.d:
---
struct S(alias func)
{
void call() { func(); }
}
extern(C) int printf(in char*, ...);
void f(int i = 77)
{
void g() { printf("i = %d;\n", i); assert(i == 77); }
S!g().call();
}
---
main.d:
---
import a;
void main() { f(); }
---
Command line (Windows):
---
dmd -c a.d
dmd main.d a.obj -inline -allinst
main
---
Output:
---
i = 0;
[email protected](10): Assertion failure
...
---
`a` module compilation option doesn't matter. Final executable have to be compiled with '-inline' and either '-allinst' or '-debug'.
This may be a root issue for reports Issue 13083, Issue 13244, and Issue 13286.
Comment #1 by k.hara.pg — 2014-09-02T02:44:33Z
(In reply to Denis Shelomovskij from comment #0)
> `a` module compilation option doesn't matter. Final executable have to be
> compiled with '-inline' and either '-allinst' or '-debug'.
It would be a regression in 2.066, so the issue does not reproduce with 2.065.