Bug 21961 – importC: Error: no struct-declarator-list for struct

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-05-24T09:09:29Z
Last change time
2021-06-04T21:35:57Z
Keywords
ImportC, rejects-valid
Assigned to
No Owner
Creator
Iain Buclaw

Comments

Comment #0 by ibuclaw — 2021-05-24T09:09:29Z
Empty structs are accepted as valid C, even though the behaviour is undefined. --- struct agg { }; --- C99 6.7.2.1-8: The presence of a struct-declaration-list in a struct-or-union-specifier declares a new type, within a translation unit. The struct-declaration-list is a sequence of declarations for the members of the structure or union. If the struct-declaration-list does not contain any named members, either directly or via an anonymous structure or anonymous union, the behavior is undefined. The type is incomplete until immediately after the } that terminates the list, and complete thereafter.
Comment #1 by ibuclaw — 2021-06-04T21:35:57Z
On further inspection, this is rather a GNU/Clang extension. Whilst we do have support code in D to handle empty C++ structs, I guess we'll wait and see if it shows up in the wild.