Bug 24155 – ImportC: accept C23 default initializers

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-09-24T01:39:36Z
Last change time
2023-11-15T21:04:49Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
dave287091

Comments

Comment #0 by dave287091 — 2023-09-24T01:39:36Z
Following fails to compile: struct S { int x; }; struct S s = {}; // Error: expression expected, not `}` Before C23, this was a common C extension to 0-initialize all fields (accepted by GCC, clang, and maybe MSVC (not sure on that one)). C23 has also added it to standard C.
Comment #1 by bugzilla — 2023-11-11T07:50:47Z
It was indeed added to C23, see 6.7.10.
Comment #2 by b2.temp — 2023-11-11T08:22:23Z
Import C is specified as C11 complient, not C23 (https://dlang.org/spec/importc.html#dialect)
Comment #3 by wyrlon — 2023-11-11T09:10:13Z
But it works on other C99 compilers despite that it's not standardized until C23, so there is a lot of code out there, depending on this.
Comment #4 by dlang-bot — 2023-11-12T04:16:00Z
@WalterBright created dlang/dmd pull request #15801 "fix Issue 24155 - ImportC: accept C23 default initializers" fixing this issue: - fix Issue 24155 - ImportC: accept C23 default initializers https://github.com/dlang/dmd/pull/15801
Comment #5 by dlang-bot — 2023-11-15T21:04:49Z
dlang/dmd pull request #15801 "fix Issue 24155 - ImportC: accept C23 default initializers" was merged into master: - ff01f2245cc5e35447b3f619f79bfc4eaac13741 by Walter Bright: fix Issue 24155 - ImportC: accept C23 default initializers https://github.com/dlang/dmd/pull/15801