Commit d6271e5
committed
fix alignment computation for nested objects
The alignment of a nested object (in C layouts) is not affected by the
alignment of its parent container when computing a field offset. This
can be strongly counter-intuitive (as it implies adding padding where it
does not seem to provide value), but is required to match the C standard.
It also permits users to write custom allocators which happen to provide
alignment in excess of that which codegen may assume is guaranteed, and
get the behavioral characteristics they intended to specify (without
resorting to computing explicit padding).
Addresses #57713 (comment)1 parent a97137e commit d6271e5
File tree
4 files changed
+45
-24
lines changed- doc/src/manual
- src
- test
4 files changed
+45
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
550 | | - | |
551 | | - | |
552 | 550 | | |
553 | 551 | | |
554 | 552 | | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
559 | 558 | | |
560 | 559 | | |
561 | 560 | | |
| |||
628 | 627 | | |
629 | 628 | | |
630 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
631 | 634 | | |
632 | 635 | | |
633 | 636 | | |
| |||
674 | 677 | | |
675 | 678 | | |
676 | 679 | | |
677 | | - | |
678 | | - | |
| 680 | + | |
679 | 681 | | |
680 | 682 | | |
681 | 683 | | |
682 | | - | |
| 684 | + | |
683 | 685 | | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
684 | 690 | | |
685 | 691 | | |
686 | 692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3103 | 3103 | | |
3104 | 3104 | | |
3105 | 3105 | | |
3106 | | - | |
3107 | | - | |
3108 | | - | |
3109 | | - | |
3110 | | - | |
| 3106 | + | |
3111 | 3107 | | |
3112 | 3108 | | |
3113 | 3109 | | |
| |||
3571 | 3567 | | |
3572 | 3568 | | |
3573 | 3569 | | |
3574 | | - | |
| 3570 | + | |
3575 | 3571 | | |
3576 | 3572 | | |
3577 | 3573 | | |
| |||
4133 | 4129 | | |
4134 | 4130 | | |
4135 | 4131 | | |
| 4132 | + | |
4136 | 4133 | | |
4137 | 4134 | | |
4138 | 4135 | | |
4139 | | - | |
| 4136 | + | |
4140 | 4137 | | |
4141 | 4138 | | |
4142 | 4139 | | |
| |||
4343 | 4340 | | |
4344 | 4341 | | |
4345 | 4342 | | |
4346 | | - | |
| 4343 | + | |
4347 | 4344 | | |
4348 | 4345 | | |
4349 | 4346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
| 303 | + | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
306 | 307 | | |
307 | 308 | | |
308 | 309 | | |
| |||
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
320 | | - | |
321 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
322 | 327 | | |
323 | 328 | | |
324 | 329 | | |
| |||
723 | 728 | | |
724 | 729 | | |
725 | 730 | | |
726 | | - | |
727 | | - | |
728 | 731 | | |
| 732 | + | |
| 733 | + | |
729 | 734 | | |
730 | 735 | | |
731 | 736 | | |
| |||
769 | 774 | | |
770 | 775 | | |
771 | 776 | | |
772 | | - | |
773 | | - | |
774 | 777 | | |
775 | 778 | | |
776 | 779 | | |
| |||
939 | 942 | | |
940 | 943 | | |
941 | 944 | | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
942 | 953 | | |
943 | 954 | | |
944 | 955 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5773 | 5773 | | |
5774 | 5774 | | |
5775 | 5775 | | |
| 5776 | + | |
| 5777 | + | |
| 5778 | + | |
| 5779 | + | |
| 5780 | + | |
| 5781 | + | |
| 5782 | + | |
5776 | 5783 | | |
5777 | 5784 | | |
5778 | 5785 | | |
| |||
0 commit comments