File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,14 @@ $(H2 $(LNAME2 delegates, Delegates))
68
68
function's stack frame (nested functions).
69
69
)
70
70
71
- $(H2 $(LNAME2 structs, Structs))
71
+ $(H2 $(LNAME2 structs, Structs and Unions ))
72
72
73
- $(P Conforms to the target's C ABI struct layout.)
73
+ $(P These conform to the target's C ABI struct layout, except:)
74
+
75
+ * An `extern(D)` struct or union with no fields has size 1, not 0.
76
+ See $(DDSUBLINK spec/struct, struct_layout, Struct Layout).
77
+ * Unions are $(RELATIVE_LINK2 name_mangling, name-mangled) as if they were structs.
78
+ * The rest of this document treats unions extrinsically the same as structs.
74
79
75
80
$(H2 $(LNAME2 classes, Classes))
76
81
Original file line number Diff line number Diff line change @@ -176,7 +176,18 @@ $(H2 $(LNAME2 struct_layout, Struct Layout))
176
176
the first field and the start of the object.
177
177
)
178
178
179
- $(P Structs with no fields of non-zero size (aka $(I Empty Structs)) have a size of one byte.)
179
+ $(P $(DDSUBLINK spec/attribute, linkage, `extern(D)`) structs with no fields of non-zero
180
+ size (aka $(I Empty Structs)) have a size of one byte.)
181
+
182
+ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
183
+ ---
184
+ extern(C) struct C {}
185
+ struct D {}
186
+
187
+ static assert(C.sizeof == 0);
188
+ static assert(D.sizeof == 1);
189
+ ---
190
+ )
180
191
181
192
$(P Non-static $(RELATIVE_LINK2 nested, function-nested D structs), which access the context of
182
193
their enclosing scope, have an extra field.
You can’t perform that action at this time.
0 commit comments