[Issue 21038] New: Wrong codegen when calling wcslen
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jul 11 17:15:35 UTC 2020
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 at puremagic.com
Reporter: tim.dlang at 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.
--
More information about the Digitalmars-d-bugs
mailing list