Bug 20898 – order dependency in evaluating pragma(inline) for functions

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-06-06T03:12:01Z
Last change time
2024-12-13T19:09:02Z
Keywords
pull
Assigned to
No Owner
Creator
Walter Bright
Moved to GitHub: dmd#19715 →

Comments

Comment #0 by bugzilla — 2020-06-06T03:12:01Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19715 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB