Consider the following sniplet:
----------------------------------------------------------
template E(){
enum E=["123"][0][$-1];
}
pragma(msg, E!());
import std.stdio;
void main() {
writeln(E!());
}
----------------------------------------------------------
Compiling with "dmd" (r287) gives:
----------------------------------------------------------
(["123"][0u])[__dollar - 1u]
Undefined symbols:
"_D1a6__T1EZ8__dollark", referenced from:
_D1a6__T1EZ8__dollark$non_lazy_ptr in a.o
(maybe you meant: _D1a6__T1EZ8__dollark$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status
--- errorlevel 1
----------------------------------------------------------
where the expected output from the compiler should be:
----------------------------------------------------------
'3'
----------------------------------------------------------
and links the binary successfully.
Comment #1 by kennytm — 2010-02-07T08:33:11Z
A simpler test case is
import std.stdio;
enum E=["123"][0][$-1];
void main() { writeln(E); }
No templates required.
Comment #2 by clugdbug — 2010-02-07T12:18:46Z
Should the title be '... unresolved at link time' ? If so, it applies to Windows as well.
Comment #3 by clugdbug — 2010-06-08T14:19:09Z
Even simpler test case:
----
static const E=["123"][0][$-1];
----
bug.d(1): Error: non-constant expression (["123"][0u])[__dollar - 1u]
This is a constant-folding issue.