D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17112 - Simple writeln call produces cryptic error message
Summary: Simple writeln call produces cryptic error message
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Mac OS X
: P1 normal
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2017-01-22 06:12 UTC by Gillett
Modified: 2018-07-01 19:58 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Gillett 2017-01-22 06:12:36 UTC
some working example code:
$ dmd --version
DMD64 D Compiler v2.072.2
Copyright (c) 1999-2016 by Digital Mars written by Walter Bright
$ dmd degenerate.d
Undefined symbols for architecture x86_64:
  "_D3std6format18__T10FormatSpecTaZ10FormatSpec6fillUpMFNaZv", referenced from:
      _D3std6format18__T10FormatSpecTaZ10FormatSpec63__T17writeUpToNextSpecTS3std5array17__T8AppenderTAyaZ8AppenderZ17writeUpToNextSpecMFNaS3std5array17__T8AppenderTAyaZ8AppenderZb in degenerate.o
      _D3std6format18__T10FormatSpecTaZ10FormatSpec59__T17writeUpToNextSpecTS3std5stdio4File17LockingTextWriterZ17writeUpToNextSpecMFS3std5stdio4File17LockingTextWriterZb in degenerate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
-----------------<degenerate.d>------------------
import std.stdio;

void main(){
    writeln(["string1", "string2"]);
}

-------------------------------------------------
a more realistic example which causes the same error:
-----------------<realistic.d>-------------------
import std.stdio;     // for writeln
import std.algorithm; // for map
import std.conv;      // for to!string
import std.range;     // for iota

string[] substrings(string n) {
    // returns a "sliding window" array of substrings of n
    return iota(1,8).map!(i => n[i..(i+3)]).array;
}

void main(){
    int[] n = [0,1,2,3,4,5,6,7,8,9];
    writeln(n.map!(to!string).join.substrings); // <------------ this line causes the error
    writeln(n.map!(to!string).join.substrings.join(",")); // <-- this would be the fix
}
-------------------------------------------------
i think this is a regression because this error was not happening before i updated dmd to v2.072.2.
Comment 1 Gillett 2017-01-22 06:14:57 UTC
issue 16661 - https://issues.dlang.org/show_bug.cgi?id=16661 - seemed to have the same error but in a different form. it was the only issue i found that had a similar error message after searching around for a bit
Comment 2 Nick Treleaven 2018-07-01 19:58:15 UTC
This works with dmd-nightly on run.dlang.io.