Bug 23066 – importC: cannot initialize char array with string literal of different length

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-04-28T06:48:56Z
Last change time
2022-05-15T18:43:57Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
duser

Comments

Comment #0 by duser — 2022-04-28T06:48:56Z
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
Comment #1 by bugzilla — 2022-04-30T04:05:45Z
char s1[2] = "toolong"; // gcc and clang give a warning on this, dmc gives error char s2[50] = "tooshort"; // well, that should work C11 6.7.9-2 says: No initializer shall attempt to provide a value for an object not contained within the entity being initialized. I interpret that as the s1 example should be an error.
Comment #2 by dlang-bot — 2022-04-30T22:05:09Z
@WalterBright created dlang/dmd pull request #14046 "fix Issue 23066 - importC: cannot initialize char array with string l…" fixing this issue: - fix Issue 23066 - importC: cannot initialize char array with string literal of different length https://github.com/dlang/dmd/pull/14046
Comment #3 by dlang-bot — 2022-05-06T07:13:57Z
dlang/dmd pull request #14046 "fix Issue 23066 - importC: cannot initialize char array with string l…" was merged into stable: - 5a55e369dbd8fafa26b6cfbb4627b8d24f5d31bb by Walter Bright: fix Issue 23066 - importC: cannot initialize char array with string literal of different length https://github.com/dlang/dmd/pull/14046
Comment #4 by dlang-bot — 2022-05-15T18:43:57Z
dlang/dmd pull request #14130 "merge stable" was merged into master: - fbe7bf2a7e2ba8e6e44b3a641b2a7b61d4869d64 by Walter Bright: fix Issue 23066 - importC: cannot initialize char array with string literal of different length (#14046) https://github.com/dlang/dmd/pull/14130