File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,15 @@ for field in struct.fields_in_declaration_order() {
226226struct.size = current_offset + padding_needed_for(current_offset, struct.alignment);
227227```
228228
229+ <div class =" warning " >
230+
231+ Warning: The function used to calculate the needed padding in this pseudocode is
232+ a naive implementation that doesn't account for overflow issues. For a rigorous
233+ implementation suitable for performing this calculation in actual code, see the
234+ source code for [ ` Layout::padding_needed_for ` ] .
235+
236+ </div >
237+
229238> Note: This algorithm can produce zero-sized structs. This differs from
230239> C where structs without data still have a size of one byte.
231240
@@ -374,3 +383,4 @@ used with any other representation.
374383[ `C` ] : #the-c-representation
375384[ primitive representations ] : #primitive-representations
376385[ `transparent` ] : #the-transparent-representation
386+ [ `Layout::padding_needed_for` ] : ../std/alloc/struct.Layout.html#method.padding_needed_for
You can’t perform that action at this time.
0 commit comments