www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23066] New: importC: can't initialize char array with string

https://issues.dlang.org/show_bug.cgi?id=23066

          Issue ID: 23066
           Summary: importC: can't initialize char array with string
                    literal of different length
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC, rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: duser neet.fi
                CC: duser neet.fi

char s1[2] = "toolong"; // Error: cannot implicitly convert expression
`"toolong"` of type `char[8]` to `char[2]`
char s2[50] = "tooshort"; // ok
void fn()
{
        char s3[2] = "toolong"; // Error: mismatched array lengths, 2 and 8
        char s4[50] = "tooshort"; // Error: mismatched array lengths, 50 and 9
}

these worked before https://github.com/dlang/dmd/pull/14027

--
Apr 27 2022