[Issue 13112] New: Ignore constness when copying dynamic array argument to static array parameter
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jul 12 10:34:42 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13112
Issue ID: 13112
Summary: Ignore constness when copying dynamic array argument
to static array parameter
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: enhancement
Priority: P4
Component: DMD
Assignee: nobody at puremagic.com
Reporter: thecybershadow at gmail.com
void f(char[1] arr) {}
void main()
{
string s;
f(s);
}
This program currently doesn't compile:
test.d(6): Error: function test.f (char[1] arr) is not callable using argument
types (string)
However, the conversion is safe, because a copy is implicitly created during
dynamic->static conversion, and the array type (char) has no indirections.
Note that this limitation only seems to apply to function parameters, as the
following works fine:
string s; char[1] arr = s;
--
More information about the Digitalmars-d-bugs
mailing list