Compiler is calling `_memset64` in betterC

Koro KoromoriX at
Sun Oct 18 16:04:55 UTC 2020

I'm writing a 'betterC' program and the compiler is generating a 
call to '_memset64' if I have an array literal where the elements 
are the same.

extern(C) void main() {
	f([1, 1]);

void f(scope immutable ulong[] a) {}

Running `dmd -betterC app.d` fails with:

/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: app.o: in function `main':
app.d:(.text.main[main]+0x24): undefined reference to `_memset64'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1

I don't want to link to additional libraries (planning to target 
WASM). The code works if I write `ulong i = 1; f([i, i]);`, but 
I'd rather the code worked without having to trick the compiler. 
Is there a compiler flag I could set to prevent D from inserting 
calls to '_memset64'?

More information about the Digitalmars-d-learn mailing list