Bug 15794 – Lambda cannot get a chance to run its codegen

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-03-13T18:33:00Z
Last change time
2017-08-02T08:07:30Z
Keywords
link-failure, pull
Assigned to
nobody
Creator
simen.kjaras

Comments

Comment #0 by simen.kjaras — 2016-03-13T18:33:46Z
The following program fails to link because the lambda on line 26 is mangled differently in functions fun and gun: struct Foo { static void fun(Holder)() { pragma(msg, "Mangled name in fun:"); pragma(msg, Holder.fn.mangleof); pragma(msg, ""); int i = Holder.fn(); } } struct Holder(alias Fn) { alias fn = Fn; } void gun(alias fn, U...)() { Foo.fun!(Holder!fn)(); pragma(msg, "Mangled name in gun:"); pragma(msg, fn.mangleof); pragma(msg, ""); static if (U.length > 0) { return gun!U; } } unittest { gun!(() => 0)(); // Line 26 }
Comment #1 by simen.kjaras — 2016-03-14T06:15:14Z
A little more info: The exact error message given: Error 42: Symbol Undefined _D3bar15__unittestL25_1FZ9__lambda1FNaNbNiNfZi And the actual symbols in the object file. Notice the lambda is not mentioned there at all: Publics by name module __D3bar9__modtestFZv bar __Dmain bar _D18TypeInfo_S3bar3Foo6__initZ bar _D3bar12__ModuleInfoZ bar _D3bar15__unittest_failFiZv bar _D3bar15__unittestL25_1FZv bar _D3bar3Foo6__initZ bar _D3bar3Foo83__T3funTS3bar60__T6HolderS46_D3bar15__unittestL25_1FZ9__lambda1FNaNbNiNfZiZ6HolderZ3funFNaNbNiNfZv bar _D3bar57__T3gunS46_D3bar15__unittestL25_1FZ9__lambda1FNaNbNiNfZiZ3gunFNaNbNiNfZv bar _D3bar60__T6HolderS46_D3bar15__unittestL25_1FZ9__lambda1FNaNbNiNfZiZ6Holder6__initZ bar _D3bar7__arrayZ bar _D3bar8__assertFiZv bar _D6__main12__ModuleInfoZ bar _D6__main15__unittest_failFiZv bar _D6__main7__arrayZ bar _D6__main8__assertFiZv bar _D83TypeInfo_S3bar60__T6HolderS46_D3bar15__unittestL25_1FZ9__lambda1FNaNbNiNfZiZ6Holder6__initZ bar _main bar Publics by module bar _D6__main15__unittest_failFiZv __Dmain _D6__main12__ModuleInfoZ _D6__main7__arrayZ _D3bar7__arrayZ _D6__main8__assertFiZv _D83TypeInfo_S3bar60__T6HolderS46_D3bar15__unittestL25_1FZ9__lambda1FNaNbNiNfZiZ6Holder6__initZ _D3bar8__assertFiZv _D3bar60__T6HolderS46_D3bar15__unittestL25_1FZ9__lambda1FNaNbNiNfZiZ6Holder6__initZ __D3bar9__modtestFZv _D3bar12__ModuleInfoZ _D3bar3Foo83__T3funTS3bar60__T6HolderS46_D3bar15__unittestL25_1FZ9__lambda1FNaNbNiNfZiZ6HolderZ3funFNaNbNiNfZv _D18TypeInfo_S3bar3Foo6__initZ _D3bar15__unittest_failFiZv _D3bar57__T3gunS46_D3bar15__unittestL25_1FZ9__lambda1FNaNbNiNfZiZ3gunFNaNbNiNfZv _D3bar15__unittestL25_1FZv _D3bar3Foo6__initZ _main
Comment #2 by k.hara.pg — 2016-03-14T13:03:35Z
(In reply to Simen Kjaeraas from comment #1) > Notice the lambda is not > mentioned there at all: That's the root cause. The aliased lambda function will get no chance to generate its code, so if it's actually used, the link-failure happens. Mangling is not related to the issue.
Comment #3 by k.hara.pg — 2016-03-14T14:02:32Z
Comment #4 by github-bugzilla — 2016-03-15T08:47:58Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/23c957a0d3a415e5f0f3e68e774b73fa3a86b044 fix Issue 15794 - Lambda cannot get a chance to run its codegen https://github.com/D-Programming-Language/dmd/commit/e9073a775b88972d34b115c1bb62a3f64173667b Merge pull request #5523 from 9rnsr/fix15794 Issue 15794 - Lambda cannot get a chance to run its codegen
Comment #5 by github-bugzilla — 2017-08-02T08:07:30Z
Commit pushed to dmd-cxx at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/7df88627e5c9de77516491ec6b6a9359fea4a1a7 Issue 15794 - Lambda cannot get a chance to run its codegen