Bug 3779 – ["123"][0][$-1] causes __dollar unresolved in compile-time.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-02-07T08:21:00Z
Last change time
2014-02-15T02:44:24Z
Keywords
link-failure, rejects-valid
Assigned to
nobody
Creator
kennytm
Blocks
4298

Comments

Comment #0 by kennytm — 2010-02-07T08:21:04Z
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.
Comment #4 by bugzilla — 2011-04-23T15:49:56Z
Comment #5 by kennytm — 2011-04-30T11:52:44Z
Fixed on D2 as well.