Bug 16313 – Duplicate symbol generated

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2016-07-23T07:11:35Z
Last change time
2017-11-02T08:58:41Z
Assigned to
No Owner
Creator
Jorge Lima

Comments

Comment #0 by jmalima69 — 2016-07-23T07:11:35Z
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 }
Comment #1 by jmalima69 — 2016-11-25T16:34:07Z
Hello, I tested the code snippet with dmd-2.072.0 under Linux64bit and the problem is gone (it was still present with dmd-2.071.2). Even though this bug report was never addressed. I will test it under windows and and MacOS asap and will update this report accordingly. JLima
Comment #2 by razvan.nitu1305 — 2017-11-01T14:00:25Z
Just tested on Windows with git HEAD and the issue is still present. On Ubuntu 16.04 the issue is not present. Changing description to Windows
Comment #3 by jmalima69 — 2017-11-01T22:37:09Z
(In reply to RazvanN from comment #2) > Just tested on Windows with git HEAD and the issue is still present. On > Ubuntu 16.04 the issue is not present. Changing description to Windows I tested before with release 2.072.0 and the problem was fixed. See my previous comment from 2016-11-25. However. at the time, I didn't check on all platforms Triggered by your comment, I tested now the release 2.076.1 on the following platforms Ubuntu 16.04 64bit: passed OS X 10.10: passed Windows 10 64bit: failed but due to a different issue. See below. > dmd snippet.d OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html teste.obj(teste) Offset 00370H Record Type 009D Error 16: Index Range Error: linker exited with status 1 I noticed OPTLINK is for Win32. Weird! So I passed the option -m64 to dmd to force it to use the microsoft linker. > dmd -m64 snippet.d And it compiled the snippet without errors. So I would say this problem seems to be fixed!
Comment #4 by razvan.nitu1305 — 2017-11-02T08:58:41Z
(In reply to Jorge Lima from comment #3) > (In reply to RazvanN from comment #2) > > Just tested on Windows with git HEAD and the issue is still present. On > > Ubuntu 16.04 the issue is not present. Changing description to Windows > > I tested before with release 2.072.0 and the problem was fixed. See my > previous comment from 2016-11-25. However. at the time, I didn't check on > all platforms > Triggered by your comment, I tested now the release 2.076.1 on the following > platforms > > Ubuntu 16.04 64bit: passed > OS X 10.10: passed > Windows 10 64bit: failed but due to a different issue. See below. > > > dmd snippet.d > OPTLINK (R) for Win32 Release 8.00.17 > Copyright (C) Digital Mars 1989-2013 All rights reserved. > http://www.digitalmars.com/ctg/optlink.html > teste.obj(teste) Offset 00370H Record Type 009D > Error 16: Index Range > Error: linker exited with status 1 > > I noticed OPTLINK is for Win32. Weird! So I passed the option -m64 to dmd > to force it to use the microsoft linker. > > > dmd -m64 snippet.d > > And it compiled the snippet without errors. > > So I would say this problem seems to be fixed! Cool! I had the same error weird error and I thought that was the issue. Thanks a lot. Closing as fixed