digitalmars.D.bugs - [Issue 21038] New: Wrong codegen when calling wcslen
- d-bugmail puremagic.com (44/44) Jul 11 2020 https://issues.dlang.org/show_bug.cgi?id=21038
https://issues.dlang.org/show_bug.cgi?id=21038 Issue ID: 21038 Summary: Wrong codegen when calling wcslen Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: tim.dlang t-online.de The result of wcslen can be too low when compiling with dmd 2.093. Consider the following two files: //////////////////// testabcd.d /////////////////// import core.stdc.stddef; import core.stdc.stdio; import core.stdc.wchar_; const(wchar_t)* name = "abcd"; void test() { size_t length = wcslen(name); printf("length: %zd\n", length); printf("data: \""); for(const(wchar_t)* s = name; *s; s++) printf("%c", *s); printf("\"\n"); } /////////////////////////////////////////////////// //////////////////// testxyzw.d /////////////////// import testabcd; void main() { test(); } /////////////////////////////////////////////////// Running it results in the following output: length: 3 data: "abcd" The correct length would be 4. When compiling with ldc it works as expected. The filenames are important. When testxyzw.d is renamed to testx.d it produces the expected output. --
Jul 11 2020