[Issue 13415] New: '-inline' causes wrong enclosing scope pointer for nested function called from templated struct
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Sep 1 11:56:22 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13415
Issue ID: 13415
Summary: '-inline' causes wrong enclosing scope pointer for
nested function called from templated struct
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: wrong-code
Severity: critical
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: verylonglogin.reg at gmail.com
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;
core.exception.AssertError at a.d(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.
--
More information about the Digitalmars-d-bugs
mailing list