digitalmars.D - pragma(inline) doesnt work on local functions : DMD
- claptrap (12/12) Sep 02 2024 Seems like an oversight?
 - RazvanN (7/19) Sep 03 2024 As per the docs [1]: "If at the declaration level, it affects the
 - Johan (6/26) Sep 03 2024 I consider this a bug. Note there is no semicolon after the
 - Walter Bright (2/3) Sep 03 2024 Please submit bugs to bugzilla!
 
Seems like an oversight?
```d
int Foo()
{
     pragma(inline,true)
     int GetFoo() { return 42; }
     return GetFoo();
}
```
GetFoo isn't inlined, but inlines OK if you pass -inline to the 
compiler
Also inlines OK if you define GetFoo outside of Foo
 Sep 02 2024
On Monday, 2 September 2024 at 22:16:53 UTC, claptrap wrote:
 Seems like an oversight?
 ```d
 int Foo()
 {
     pragma(inline,true)
     int GetFoo() { return 42; }
     return GetFoo();
 }
 ```
 GetFoo isn't inlined, but inlines OK if you pass -inline to the 
 compiler
 Also inlines OK if you define GetFoo outside of Foo
As per the docs [1]: "If at the declaration level, it affects the 
functions declared in the block it controls. If inside a 
function, it affects the function it is enclosed by". So you 
probably just need to put the pragma(inline) in GetFoo.
RazvanN
[1] https://dlang.org/spec/pragma.html#inline
 Sep 03 2024
On Tuesday, 3 September 2024 at 14:05:40 UTC, RazvanN wrote:On Monday, 2 September 2024 at 22:16:53 UTC, claptrap wrote:I consider this a bug. Note there is no semicolon after the pragma, so it is at declaration level (declaration of `GetFoo`). In the test case, current frontend applies the pragma to `Foo` which I think is wrong (because no semicolon after the pragma). -JohanSeems like an oversight? ```d int Foo() { pragma(inline,true) int GetFoo() { return 42; } return GetFoo(); } ``` GetFoo isn't inlined, but inlines OK if you pass -inline to the compiler Also inlines OK if you define GetFoo outside of FooAs per the docs [1]: "If at the declaration level, it affects the functions declared in the block it controls. If inside a function, it affects the function it is enclosed by". So you probably just need to put the pragma(inline) in GetFoo.
 Sep 03 2024
On 9/3/2024 10:16 AM, Johan wrote:I consider this a bug.Please submit bugs to bugzilla!
 Sep 03 2024








 
 
 
 Walter Bright <newshound2 digitalmars.com>