[Issue 21437] New: const(char*) variable matches both const(char)[] and const(char)*
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Nov 29 20:42:43 UTC 2020
    
    
  
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 at puremagic.com
          Reporter: elpenguino+D at 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)*).
--
    
    
More information about the Digitalmars-d-bugs
mailing list