Bug 21437 – const(char*) variable matches both const(char)[] and const(char)*

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-11-29T20:42:43Z
Last change time
2024-12-13T19:13:06Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
elpenguino+D
Moved to GitHub: dmd#19830 →

Comments

Comment #0 by elpenguino+D — 2020-11-29T20:42:43Z
``` 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)*).
Comment #1 by robert.schadek — 2024-12-13T19:13:06Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19830 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB