[Issue 15671] New: The compiler should take into account inline pragmas when inlining
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Feb 10 14:28:17 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15671
Issue ID: 15671
Summary: The compiler should take into account inline pragmas
when inlining
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: schveiguy at yahoo.com
Given the following code:
import std.random;
shared int x;
void longFunc()
{
version(good)
x = uniform!int();
x = uniform!int();
x = uniform!int();
x = uniform!int();
x = uniform!int();
x = uniform!int();
x = uniform!int();
}
void foo(alias func)()
{
pragma(inline, true);
func();
x = uniform!int();
}
void main()
{
foo!longFunc();
}
The compiler fails if passed the -inline command line switch. However, it
succeeds if -inline -version=good is passed
Here is what happens:
1. The compiler inlines longFunc into foo (perhaps even calls to uniform as
well)
2. The compiler tries to inline foo into main, but fails because of the inlined
call to longFunc.
3. Since pragma(inline, true) is specified for foo, this fails to compile.
However, the compiler could succeed inlining foo into main by not inlining
longFunc into foo first.
This is demonstrated by the version=good compilation (one extra call to uniform
prevents longFunc from being inlined)
--
More information about the Digitalmars-d-bugs
mailing list