Bug 18010 – Undefined reference to _d_arraycopy when copying arrays in -betterC

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2017-11-25T03:56:48Z
Last change time
2018-11-13T05:02:46Z
Keywords
betterC
Assigned to
No Owner
Creator
Mike Franklin

Comments

Comment #0 by slavo5150 — 2017-11-25T03:56:48Z
From: http://forum.dlang.org/post/[email protected] --------------------------------- import core.stdc.stdio; import std.algorithm : min; extern (C) void main() { char[256] buf; buf[] = '\0'; auto str = "hello world"; auto ln = min(buf.length, str.length); buf[0..ln] = str[0..ln]; printf("%s\n", buf.ptr); } rdmd -betterC bettercarray2.d /tmp/.rdmd-1000/rdmd-bettercarray2.d-435C14EC3DAF09FFABF8ED6919B624C1/objs/bettercarray2.o: In function `main': bettercarray2.d:(.text.main[main]+0xbc): undefined reference to `_d_arraycopy' collect2: error: ld returned 1 exit status Error: linker exited with status 1 --------------------------------- If I add -noboundscheck flag all works fine.
Comment #1 by b2.temp — 2017-11-25T05:11:54Z
(In reply to Mike from comment #0) --------------------------- > > If I add -noboundscheck flag all works fine. Actually there's a random return code, the test case you provided is a "compilable" test. "runnable" is rather (after reduction) --- extern (C) int main() { char[256] buf; char[] str; buf[0..0] = str[0..0]; return 0; } ---
Comment #2 by bugzilla — 2018-02-10T10:15:29Z
> -noboundscheck The trouble is dmd is relying on _d_arraycopy() to do the bounds check, and just uses memcpy() otherwise.
Comment #3 by bugzilla — 2018-02-11T08:41:33Z
Comment #4 by github-bugzilla — 2018-11-13T05:02:46Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d075a24e726e6567e09a4a9a3164d7ab74cd2e66 fix Issue 18010 - Undefined reference to _d_arraycopy when copying arrays in -betterC https://github.com/dlang/dmd/commit/50fc827eaa9b8e4d0ca932f939051c0c6c63043c Merge pull request #7867 from WalterBright/fix18010 fix Issue 18010 - Undefined reference to _d_arraycopy when copying ar…