digitalmars.D.bugs - [Issue 21437] New: const(char*) variable matches both const(char)[]
- d-bugmail puremagic.com (27/27) Nov 29 2020 https://issues.dlang.org/show_bug.cgi?id=21437
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)*). --
Nov 29 2020