[Issue 20766] New: empty string literals passed as optional parameter should not be 0 terminated
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Apr 25 07:22:47 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20766
Issue ID: 20766
Summary: empty string literals passed as optional parameter
should not be 0 terminated
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: b2.temp at gmx.com
concrete illustration:
---
void main()
{
test();
}
void test(string s = "")
{
if (s) {}
else { assert(false); }
s ? {} : assert(false);
}
---
`""` is actually a pointer to 0x00 and a length of 0. Since `s.ptr` will never
be null the else branch (or the last exp of a CondExpr) will never be executed,
even when calling test() without argument.
--
More information about the Digitalmars-d-bugs
mailing list