Normally pragma Optimize_Alignment (Space) forces an alignment of 1 for any packed record, but we can't do that for a variable length record, since we can't implement that case, so ignore the pragma in this case with a warning.
The following test program shows the patch in action: 1. pragma optimize_alignment (space); 2. procedure testalign is 3. subtype Continuous_Values is float; 4. type Continuous_Values_Map is 5. array ( integer range <> ) of Continuous_Values; 6. 7. type my_record (s : integer) is record | >>> Optimize_Alignment has no effect for "my_record" >>> pragma is ignored for variable length record 8. x : continuous_values_map (1 .. s); 9. end record; 10. pragma pack (my_record); 11. 12. type my_record2 (s : integer) is record 13. x : continuous_values_map (1 .. 1000); 14. end record; 15. pragma pack (my_record2); 16. 17. begin 18. null; 19. end; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-10-29 Robert Dewar <de...@adacore.com> * layout.adb (Set_Composite_Alignment): Ignore pragma Optimize_Alignment (Space) for packed variable length records.
Index: layout.adb =================================================================== --- layout.adb (revision 192918) +++ layout.adb (working copy) @@ -2882,7 +2882,12 @@ and then Is_Packed (E) and then not Is_Atomic (E) then - Align := 1; + if not Size_Known_At_Compile_Time (E) then + Error_Msg_N ("Optimize_Alignment has no effect for &", E); + Error_Msg_N ("\pragma is ignored for variable length record?", E); + else + Align := 1; + end if; -- Not a record, or not packed