https://issues.dlang.org/show_bug.cgi?id=16313
Issue ID: 16313
Summary: Duplicate symbol generated
Product: D
Version: D2
Hardware: x86_64
OS: Mac OS X
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
The compiler generates duplicated symbols for "my_array" in the following code
snippet and causes the linker to fail.
The issue is triggered by the circular reference in line 18 (which is perfectly
legal btw). Commenting that line and the error goes away. This issue is present
in 2.071.1 on OSX and windows at least, but not present in version 2.067.1, at
least not in OSX or linux.
01 struct Foo {
02 int a;
03 immutable(Foo[])* b;
04 this(int _a, immutable(Foo[])* _b)
05 {
06 a = _a;
07 b = _b;
08 }
09 this(int _a)
10 {
11 this(_a, null);
12 }
13 };
14
15 immutable Foo[] my_array = [
16 Foo(1),
17 Foo(2),
18 Foo(3, &my_array),
19 ];
20
21 void main()
22 {
23 int a = my_array[0].a;
24 }
--