November 29, 2020 [Issue 21437] New: const(char*) variable matches both const(char)[] and const(char)* | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21437 Issue ID: 21437 Summary: const(char*) variable matches both const(char)[] and const(char)* Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: rejects-valid Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: elpenguino+D@gmail.com ``` void fun(const(char)[] a) {} void fun(const(char)* a) {} const(char*) a = "a"; void main() { fun(a); } ``` Without the literal to initialize it, it chooses fun(const(char)*) as expected. With it, the compiler thinks both match and cannot choose. It should always choose fun(const(char)*). -- |
Copyright © 1999-2021 by the D Language Foundation