Bug 20689 – dmd's -betterC mode generates "undefined reference to '_memsetFloat'" when using float arrays

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-03-20T05:37:36Z
Last change time
2022-06-08T10:24:27Z
Keywords
betterC
Assigned to
No Owner
Creator
E Cruz

Comments

Comment #0 by cruz.dlang — 2020-03-20T05:37:36Z
The following program fails to link when using dmd versions 2.090.0 and 2.091.0 on linux: import core.stdc.stdio; extern (C) void main(int argc, char **argv) { float[4] f; printf("f[0] = %f\n", f[0]); } Similar error is generated when using double arrays, but int and long arrays work fine. LDC's betterC mode does not generate errors with float or double arrays. Also, explicitly initializing f allows dmd to compile the program without errors.
Comment #1 by blatblatnik — 2021-04-30T21:06:12Z
This does actually happen with other types of arrays as well. See [Issue 21879]. Although for integer array types it only happens if you try to assign to the arrays. For floats and doubles it probably happens even only on declaration because the default values are NaN, and the compiler emits a _memsetFloat/_memsetDouble to fill those out. Arrays generally seem pretty broken in betterC..
Comment #2 by dkorpel — 2022-06-08T10:24:27Z
*** This issue has been marked as a duplicate of issue 19946 ***