Bug 17778 – Creating a static array with duplicates in betterC causes "undefined reference to _memset32" linker failure

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-08-25T21:16:57Z
Last change time
2022-06-08T10:25:47Z
Keywords
backend, betterC
Assigned to
No Owner
Creator
Hassan
See also
https://issues.dlang.org/show_bug.cgi?id=22466

Comments

Comment #0 by azi.hassan — 2017-08-25T21:16:57Z
The following has been tested on Lubuntu 14.04 32 bits with the latest dmd beta (dmd v2.076.0-b2-dirty). Attempting to create a static int array (with a known size at compile time) that has adjacent duplicates in it seems to require an absent _memset32 function. Here's a stripped down version of the code that causes it : import core.stdc.stdio; extern(C) int main() { int[3] array = [12, 12, 11]; return 0; } Here's a second version : import core.stdc.stdio; extern(C) int main() { int[3] array; array[] = 3; return 0; } And here's the error : $ dmd -betterC -g test.d test.o : Dans la fonction « main » : /home/hassan/scripts/dailyprogrammer/test.d:5 : référence indéfinie vers « _memset32 » collect2: error: ld returned 1 exit status Error: linker exited with status 1 Arrays of bool or char compile without problem. Arrays of double or long complain about the absence of _memset64. Note that it only fails when the duplicates are adjacent. The following code compiles : import core.stdc.stdio; extern(C) int main() { char[4] letters = ['a', 'a', 'a', 'a']; int[3] numbers = [12, 11, 12]; //non-adjacent duplicates bool[6] booleans = [true, true, true, true, true, true]; long[3] longs = [12, 11, 12]; int[3] numbers = [0, 0, 0]; //zeros are fine too return 0; }
Comment #1 by aldacron — 2018-02-08T06:19:13Z
Also seeing this on Windows and run.dlang.io with string arrays: string[1] foo1 = "foo"; // _meset128ii char*[1] foo2 = "foo"; // _memset64
Comment #2 by radu.racariu — 2018-07-25T19:08:00Z
This is quite annoying. LDC behaves differently and compiles the test program. https://run.dlang.io/is/tCyjtL I think this issues deserves to get higher priority just because you get different behavior on compatible compilers. The underlying issue looks to be backed related. Might be worth including it in the #dbugdix campaign.
Comment #3 by dkorpel — 2022-06-08T10:25:47Z
*** This issue has been marked as a duplicate of issue 19946 ***