If the pragma(inline) is present in the function body, the semantic analysis of the function body must be done before the function is called in order for it to be recognized:
int test(int j) {
void bar() { pragma(inline, true); ++j; }
return foo(j);
}
int foo(int i) {
pragma(inline, true);
while (i)
i = i * 2;
return i + 1;
}
This compiles successfully with -inline switch, even though foo() is called, and is not inlined. If foo() is defined above test(), it will fail to compile.
The solution is to deprecate use of pragma(inline) inside of functions where attributes cannot be inferred. (I.e. most freestanding functions.)
Comment #1 by dlang-bot — 2020-06-06T05:35:52Z
@WalterBright created dlang/dmd pull request #11237 "fix Issue 20898 - order dependency in evaluating pragma(inline) for f…" fixing this issue:
- fix Issue 20898 - order dependency in evaluating pragma(inline) for functions
https://github.com/dlang/dmd/pull/11237
Comment #2 by bugzilla — 2020-06-06T22:06:42Z
Probably not going to be able to fix this due to the pervasive use of pragma(inline) within function bodies.
Comment #3 by robert.schadek — 2024-12-13T19:09:02Z