Bug 17155 – [REG2.071.0] Link failure with nested map

Status
NEW
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-02-07T20:56:36Z
Last change time
2024-12-13T18:51:32Z
Keywords
link-failure
Assigned to
No Owner
Creator
Vladimir Panteleev
Moved to GitHub: dmd#19232 →

Comments

Comment #0 by dlang-bugzilla — 2017-02-07T20:56:36Z
//////////////////// test.d /////////////////// import std.algorithm; import std.file; void main() { string[] files; files.map!(mask => dirEntries(".", mask, SpanMode.shallow) .map!(de => de) ); } /////////////////////////////////////////////// Works with 2.070.2. With 2.071.0, doesn't link: test.o: In function `_D3std9algorithm9iteration239__T9MapResultS584test4mainFZ18__T9__lambda1TAyaZ9__lambda1MFAyaZ9__lambda2TS3std9algorithm9iteration121__T12FilterResultS76_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZ1fMFS3std4file8DirEntryZbTS3std4file11DirIteratorZ12FilterResultZ9MapResult9__xtoHashFNbNeKxS3std9algorithm9iteration239__T9MapResultS584test4mainFZ18__T9__lambda1TAyaZ9__lambda1MFAyaZ9__lambda2TS3std9algorithm9iteration121__T12FilterResultS76_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZ1fMFS3std4file8DirEntryZbTS3std4file11DirIteratorZ12FilterResultZ9MapResultZm': test.d:(.text._D3std9algorithm9iteration239__T9MapResultS584test4mainFZ18__T9__lambda1TAyaZ9__lambda1MFAyaZ9__lambda2TS3std9algorithm9iteration121__T12FilterResultS76_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZ1fMFS3std4file8DirEntryZbTS3std4file11DirIteratorZ12FilterResultZ9MapResult9__xtoHashFNbNeKxS3std9algorithm9iteration239__T9MapResultS584test4mainFZ18__T9__lambda1TAyaZ9__lambda1MFAyaZ9__lambda2TS3std9algorithm9iteration121__T12FilterResultS76_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZ1fMFS3std4file8DirEntryZbTS3std4file11DirIteratorZ12FilterResultZ9MapResultZm+0x18): undefined reference to `_D173TypeInfo_xS3std9algorithm9iteration121__T12FilterResultS76_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZ1fMFS3std4file8DirEntryZbTS3std4file11DirIteratorZ12FilterResult6__initZ' test.d:(.text._D3std9algorithm9iteration239__T9MapResultS584test4mainFZ18__T9__lambda1TAyaZ9__lambda1MFAyaZ9__lambda2TS3std9algorithm9iteration121__T12FilterResultS76_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZ1fMFS3std4file8DirEntryZbTS3std4file11DirIteratorZ12FilterResultZ9MapResult9__xtoHashFNbNeKxS3std9algorithm9iteration239__T9MapResultS584test4mainFZ18__T9__lambda1TAyaZ9__lambda1MFAyaZ9__lambda2TS3std9algorithm9iteration121__T12FilterResultS76_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZ1fMFS3std4file8DirEntryZbTS3std4file11DirIteratorZ12FilterResultZ9MapResultZm+0x1f): undefined reference to `_D173TypeInfo_xS3std9algorithm9iteration121__T12FilterResultS76_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZ1fMFS3std4file8DirEntryZbTS3std4file11DirIteratorZ12FilterResult6__initZ' collect2: error: ld returned 1 exit status --- errorlevel 1 Introduced in https://github.com/D-Programming-Language/phobos/pull/3969 , but that seems to merely expose a latent dmd bug. Using -allinst doesn't help.
Comment #1 by dlang-bugzilla — 2017-02-12T01:16:12Z
Reduced: /////////////////////// lib.d /////////////////////// template unaryFun(alias fun) { alias unaryFun = fun; } struct MapResult(alias fun) { void front() { fun(string.init); } } template map(fun...) { auto map(string[]) { alias _fun = unaryFun!fun; assert(!is(typeof(_fun(string.init)))); return MapResult!(_fun)(); } } struct Map2Result(Range) { Range _input; } auto map2(Range)(Range) { return Map2Result!Range(); } struct FilterResult() { string front; } auto dirEntries() { return FilterResult!().init; } /////////////////////// test.d ////////////////////// import lib; version (bug) auto x (T) (T mask) { return dirEntries().map2; } else auto x(string mask) { return dirEntries().map2; } void main() { string[] files; files.map!(mask => x(mask)); } ////////////////////// test.sh ////////////////////// dmd -lib -oflib.a lib.d dmd test lib.a # OK dmd -version=bug test lib.a # link error ///////////////////////////////////////////////////// Output: test.o: In function `_D3lib56__T10Map2ResultTS3lib18__T12FilterResultZ12FilterResultZ10Map2Result9__xtoHashFNbNeKxS3lib56__T10Map2ResultTS3lib18__T12FilterResultZ12FilterResultZ10Map2ResultZm': test.d:(.text._D3lib56__T10Map2ResultTS3lib18__T12FilterResultZ12FilterResultZ10Map2Result9__xtoHashFNbNeKxS3lib56__T10Map2ResultTS3lib18__T12FilterResultZ12FilterResultZ10Map2ResultZm+0x14): undefined reference to `_D49TypeInfo_xS3lib18__T12FilterResultZ12FilterResult6__initZ' test.d:(.text._D3lib56__T10Map2ResultTS3lib18__T12FilterResultZ12FilterResultZ10Map2Result9__xtoHashFNbNeKxS3lib56__T10Map2ResultTS3lib18__T12FilterResultZ12FilterResultZ10Map2ResultZm+0x1b): undefined reference to `_D49TypeInfo_xS3lib18__T12FilterResultZ12FilterResult6__initZ' collect2: error: ld returned 1 exit status This is still a regression in 2.071.0, however, as with issue 15985, Digger's bisection doesn't seem to point to anything useful.
Comment #2 by dlang-bugzilla — 2017-02-12T03:46:16Z
(In reply to Vladimir Panteleev from comment #1) > This is still a regression in 2.071.0, however, as with issue 15985, > Digger's bisection doesn't seem to point to anything useful. OK, I got Digger to bisect the stable branch properly. Introduced in https://github.com/D-Programming-Language/dmd/pull/4995.
Comment #3 by robert.schadek — 2024-12-13T18:51:32Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19232 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB