Bug 14198 – [REG2.067a] Link failure with Variant

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-02-19T14:53:00Z
Last change time
2017-07-19T17:42:24Z
Keywords
link-failure, pull
Assigned to
nobody
Creator
k.hara.pg

Attachments

IDFilenameSummaryContent-TypeSize
1480testcase.zipReduced test case. Running ng.bat will reproduce link-failure.application/x-zip-compressed2613

Comments

Comment #0 by k.hara.pg — 2015-02-19T14:53:59Z
From: https://issues.dlang.org/show_bug.cgi?id=13167#c1 This code fails to compile with git-head, but succeeds with 2.066.1. // test.d import std.variant; void main() { Variant a = true; } $ dmd test.d DMD v2.067 DEBUG OPTLINK (R) for Win32 Release 8.00.15 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html test.obj(test) Error 42: Symbol Undefined _D3std4conv11__T2toTAyaZ9__T2toTbZ2toFbZAya --- errorlevel 1
Comment #1 by k.hara.pg — 2015-02-19T14:55:32Z
Introduced in: https://github.com/D-Programming-Language/dmd/pull/4335 But i'm not sure what is the problem.
Comment #2 by bugzilla — 2015-03-04T08:42:56Z
This reduces to: --- import std.conv; struct S { ptrdiff_t function() fptr = &handler; static ptrdiff_t handler() { static if (is(typeof(to!(string)(false)))) { to!(string)(false); } return 0; } } void main() { } --- I don't think it has anything to do with 4335, but with emitting instantiations done during a typeof.
Comment #3 by bugzilla — 2015-03-05T05:37:29Z
This is crazy complicated. What's happening is in TemplateInstance::needsCodegen(), the minst for to!string is set to std.bitmanip, which is not a root module, and so needsCodegen() says it should be in Phobos.lib. However, std.bitmanip never actually instantiates to!string, so it is not found in phobos.lib, and the link fails. _D3std4conv11__T2toTAyaZ9__T2toTbZ2toFbZAya is to!string So, to!string's minst is being set wrong. The wrong value is set by this code in TemplateInstance::semantic(): --------------- // If the first instantiation was speculative, but this is not: if (!inst->minst) { // Mark it is a non-speculative instantiation. inst->minst = minst; <---- here } --------------- minst is set to std.bitmanip during the evaluation of std.bitmanip.FloatRep, which calls: -------------- mixin(bitfields!( uint, "fraction", 23, ubyte, "exponent", 8, bool, "sign", 1)); --------------- which winds up calling to!string at some point with sc->minst set to std.bitmanip. I don't know why to!string is not emitted when Phobos is built.
Comment #4 by bugzilla — 2015-03-05T05:59:21Z
Hmm, a reference to: _D3std4conv11__T2toTAyaZ9__T2toTbZ2toFbZAya is generated, but there's a: _D3std4conv11__T2toTAyaZ9__T2toTbZ2toFNaNfbZAya in Phobos. The difference is the latter is Na (pure) and Nf (@safe). So, somehow attribute inference is happening in the latter but not the former.
Comment #5 by bugzilla — 2015-03-05T10:32:32Z
Comment #6 by k.hara.pg — 2015-03-07T14:44:26Z
Created attachment 1480 Reduced test case. Running ng.bat will reproduce link-failure. (In reply to Kenji Hara from comment #1) > Introduced in: https://github.com/D-Programming-Language/dmd/pull/4335 Sorry I was wrong. The issue commit that was introducing the change was in Phobos repository. https://github.com/D-Programming-Language/phobos/commit/a9d45235da6509e21450dea1825a5fa1dff9eed4#diff-54cf8402b22024ae667d4048a5126f0eL17 The commit has removed `import std.string;` from the module level scope in std.array. Unfortunately it triggered a previously unknown forward reference bug in compiler. See also the minimized test case I attached.
Comment #7 by github-bugzilla — 2015-03-07T18:06:15Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/646dc1969c78fdf43b981b973783efba08b11354 fix Issue 14198 - [REG2.067a] Link failure with Variant https://github.com/D-Programming-Language/phobos/commit/8598139bde54ffa8e0888b965f11e3ac79914661 Merge pull request #3038 from WalterBright/fix14198 fix Issue 14198 - [REG2.067a] Link failure with Variant
Comment #8 by github-bugzilla — 2015-03-08T00:40:54Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/77b9b31bb6484c87e45b1df787cd58a4452d05f2 fixup #3038 add reference to bugzilla issue 14198 https://github.com/D-Programming-Language/phobos/commit/74d2c8aa799297ef404055390cbf24c04c94248c Merge pull request #3044 from MartinNowak/fixup3038 fixup #3038 add reference to bugzilla issue 14198
Comment #9 by k.hara.pg — 2015-03-09T13:44:22Z
Comment #10 by github-bugzilla — 2015-03-10T03:56:28Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a5bb5a092d8917776e3d5be5a70a3ddddee48326 fix Issue 14198 - Link failure with Variant https://github.com/D-Programming-Language/dmd/commit/f22d9dbb42b6a32d5b4c7c9f3db45e07c9f8aaf6 Merge pull request #4464 from 9rnsr/fix14198 [REG2.067a] Issue 14198 - Link failure with Variant
Comment #11 by github-bugzilla — 2015-03-10T11:46:20Z
Commits pushed to 2.067 at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/4dfde4caab8fb9e12c035784d5ddf33925ea3526 Merge pull request #3038 from WalterBright/fix14198 fix Issue 14198 - [REG2.067a] Link failure with Variant https://github.com/D-Programming-Language/phobos/commit/b2bbff77fa9eebb072d9c39ee505f9db4f24d997 Merge pull request #3044 from MartinNowak/fixup3038 fixup #3038 add reference to bugzilla issue 14198
Comment #12 by github-bugzilla — 2015-04-11T12:24:57Z
Comment #13 by github-bugzilla — 2015-06-17T21:01:40Z
Comment #14 by github-bugzilla — 2015-06-17T21:03:24Z
Comment #15 by github-bugzilla — 2017-07-19T17:42:24Z
Commits pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/646dc1969c78fdf43b981b973783efba08b11354 fix Issue 14198 - [REG2.067a] Link failure with Variant https://github.com/dlang/phobos/commit/8598139bde54ffa8e0888b965f11e3ac79914661 Merge pull request #3038 from WalterBright/fix14198 https://github.com/dlang/phobos/commit/77b9b31bb6484c87e45b1df787cd58a4452d05f2 fixup #3038 add reference to bugzilla issue 14198 https://github.com/dlang/phobos/commit/74d2c8aa799297ef404055390cbf24c04c94248c Merge pull request #3044 from MartinNowak/fixup3038