Bug 3745 – Linking error with associative array of arrays
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-01-27T15:02:00Z
Last change time
2015-06-09T01:27:22Z
Keywords
link-failure
Assigned to
nobody
Creator
aifgi90
Comments
Comment #0 by aifgi90 — 2010-01-27T15:02:34Z
--file: a.d--
module a;
class A {
private int[][int] n;
public int[][int] foo() {
return n;
}
}
-------------
--file: b.d--
import std.stdio;
import a;
int main() {
A a = new A();
if (a.foo().keys.length != 0) {
foreach (key, value; a.foo()) {
writefln("%s %s", key, value);
}
}
return 0;
}
-------------
compile:
dmd -c a.d
dmd -c b.d
gcc a.o b.o -lphobos2 -lpthread -lm
...and get errors:
bug.o: In function `_Dmain':
bug.d:(.text._Dmain+0x24): undefined reference to `_D6object27__T16AssociativeArrayTiTAiZ16AssociativeArray4keysMFNdZAi'
bug.d:(.text._Dmain+0x43): undefined reference to `_D6object27__T16AssociativeArrayTiTAiZ16AssociativeArray7opApplyMFDFKiKAiZiZi'
collect2: ld returned 1 exit status
Comment #1 by aifgi90 — 2010-02-15T12:50:16Z
If rewrite a.d as:
module a;
class A {
private int[][int] n;
public int[] foo() {
return n.keys;
}
public int[][int] foo() {
return n;
}
}
It compiles fine.
Comment #2 by k.hara.pg — 2013-02-17T19:28:18Z
*** This issue has been marked as a duplicate of issue 8997 ***