File tree 1 file changed +10
-0
lines changed 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() {
226
226
struct.size = current_offset + padding_needed_for(current_offset, struct.alignment);
227
227
```
228
228
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
+
229
238
> Note: This algorithm can produce zero-sized structs. This differs from
230
239
> C where structs without data still have a size of one byte.
231
240
@@ -374,3 +383,4 @@ used with any other representation.
374
383
[ `C` ] : #the-c-representation
375
384
[ primitive representations ] : #primitive-representations
376
385
[ `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