Commit 0663968
fix alignment computation for nested objects (#57722)
The alignment of a nested object (in C layouts) is not affected by the
alignment of its parent container when computing a field offset (as if
it will be allocated at address 0). This can be strongly
counter-intuitive (as it implies it should add padding where it does not
seem to provide value to the user), but this 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)
(Cherry-picked from ec3c02a in
v1.11 backports branch)1 parent 4a09625 commit 0663968
File tree
4 files changed
+47
-18
lines changed- doc/src/manual
- src
- test
4 files changed
+47
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
546 | | - | |
547 | | - | |
548 | 546 | | |
549 | 547 | | |
550 | 548 | | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
555 | 554 | | |
556 | 555 | | |
557 | 556 | | |
| |||
624 | 623 | | |
625 | 624 | | |
626 | 625 | | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
627 | 630 | | |
628 | 631 | | |
629 | 632 | | |
| |||
670 | 673 | | |
671 | 674 | | |
672 | 675 | | |
673 | | - | |
674 | | - | |
| 676 | + | |
675 | 677 | | |
676 | 678 | | |
677 | 679 | | |
678 | | - | |
| 680 | + | |
679 | 681 | | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
680 | 686 | | |
681 | 687 | | |
682 | 688 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3301 | 3301 | | |
3302 | 3302 | | |
3303 | 3303 | | |
3304 | | - | |
| 3304 | + | |
3305 | 3305 | | |
3306 | 3306 | | |
3307 | 3307 | | |
| |||
3850 | 3850 | | |
3851 | 3851 | | |
3852 | 3852 | | |
| 3853 | + | |
3853 | 3854 | | |
3854 | 3855 | | |
3855 | | - | |
| 3856 | + | |
3856 | 3857 | | |
3857 | 3858 | | |
3858 | 3859 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
297 | 298 | | |
298 | 299 | | |
299 | 300 | | |
| |||
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
311 | | - | |
312 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
313 | 318 | | |
314 | 319 | | |
315 | 320 | | |
| |||
601 | 606 | | |
602 | 607 | | |
603 | 608 | | |
604 | | - | |
605 | | - | |
606 | 609 | | |
| 610 | + | |
| 611 | + | |
607 | 612 | | |
608 | 613 | | |
609 | 614 | | |
| |||
648 | 653 | | |
649 | 654 | | |
650 | 655 | | |
651 | | - | |
652 | | - | |
653 | 656 | | |
654 | 657 | | |
655 | 658 | | |
| |||
825 | 828 | | |
826 | 829 | | |
827 | 830 | | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
828 | 843 | | |
829 | 844 | | |
830 | 845 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5665 | 5665 | | |
5666 | 5666 | | |
5667 | 5667 | | |
| 5668 | + | |
| 5669 | + | |
| 5670 | + | |
| 5671 | + | |
| 5672 | + | |
| 5673 | + | |
| 5674 | + | |
5668 | 5675 | | |
5669 | 5676 | | |
5670 | 5677 | | |
| |||
0 commit comments