Bug 19375 – .init of a nested struct stumps the inliner

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-11-07T20:20:36Z
Last change time
2022-12-27T23:12:10Z
Assigned to
No Owner
Creator
Stanislav Blinov
See also
https://issues.dlang.org/show_bug.cgi?id=16360

Comments

Comment #0 by stanislav.blinov — 2018-11-07T20:20:36Z
union Erase(T) { T typed; } void func(T)() { pragma(inline, true); auto e = Erase!T(T.init); } void main() { version (TestNested) { struct S { ~this() {} /* so that it's nested */ } } else { static struct S { ~this() {} } } func!S; } $ dmd -inline test.d Compiles $ dmd -inline -version=TestNested test.d test.d(3): Error: function `test.func!(S).func` cannot inline function
Comment #1 by b2.temp — 2018-11-08T04:39:01Z
just a nested type is sufficiet to prevent inlining. possibly a duplicated of https://issues.dlang.org/show_bug.cgi?id=16360
Comment #2 by stanislav.blinov — 2018-11-08T14:37:17Z
They seem to be different. In your case, it's about defining a struct inside the inlined function (note that that struct isn't event nested, i.e. __traits(isNested, S) will be false. In my case, it's about using a nested struct inside another function. Although who knows, it may indeed boil down to the same problem in DMD's code.
Comment #3 by maxhaton — 2022-12-27T23:12:10Z
Cannot reproduce with the new inliner.