Bug 3770 – Associative array with enum key causes link problems when compiled in multiple files
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2010-02-04T08:14:00Z
Last change time
2015-06-09T01:27:40Z
Assigned to
nobody
Creator
webmaster
Comments
Comment #0 by webmaster — 2010-02-04T08:14:14Z
DMD 2.040
Linux (Fedora) on x86
NOTE: I think that this is a likely dup of 3745. However, I'm posting this new defect because it is a new flavor of the problem, just in case the root causes are somewhat different.
--file: foo.d--
import std.stdio;
import bar;
void main()
{
foreach(e; ENUM_table.values)
writef("%d", e);
foreach(e; ENUM_table.keys)
writef("%d", e);
}
-------------
--file: bar.d--
enum ENUM : uint {
INVALID = 256
}
int[ENUM] ENUM_table;
-------------
compile:
dmd -c foo.d
dmd -c bar.d
gcc -m32 foo.o bar.o -L ~/d/2.0/dmd2/linux/lib -lphobos2 -lpthread -lm -o foobar
-------------
error:
foo.o: In function `_Dmain':
foo.d:(.text._Dmain+0x14): undefined reference to `_D6object35__T16AssociativeArrayTE3bar4ENUMTiZ16AssociativeArray6valuesMFNdZAi'
foo.d:(.text._Dmain+0x70): undefined reference to `_D6object35__T16AssociativeArrayTE3bar4ENUMTiZ16AssociativeArray4keysMFNdZAE3bar4ENUM'
collect2: ld returned 1 exit status
Comment #1 by webmaster — 2010-02-04T08:15:22Z
Oh, I forgot to mention: the code works just fine if you concatenate foo.d and bar.d into a single file.
Comment #2 by andrej.mitrovich — 2013-02-18T09:56:09Z
Also fixed by pull in Issue 8997.
*** This issue has been marked as a duplicate of issue 8997 ***