https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99802
Bug ID: 99802 Summary: [11 regression] Assignment of aggregate done component-by-component Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: simon at pushface dot org Target Milestone: --- Created attachment 50481 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50481&action=edit Demonstrator, with output assembler In arm-eabi-gcc version 11.0.1 20210303 (experimental) (GCC), assigning an aggregate to a memory-mapped register is performed by assigning the components of the aggregate one-by-one to the register rather than as a whole word. The same bug is present in the x86_64-apple-darwin compiler. In compiler releases up to & including 10, this was done using a whole-word assignment. with ATSAM3X8E; use ATSAM3X8E; with ATSAM3X8E.PMC; use ATSAM3X8E.PMC; procedure Clock is begin PMC_Periph.CKGR_MOR := (KEY => 16#37#, MOSCXTEN => 1, -- main crystal oscillator enable MOSCRCEN => 1, -- main on-chip rc osc. enable MOSCXTST => 8, -- startup time others => <>); end Clock; The register is a component of a record: type PMC_Peripheral is record ... CKGR_MOR : aliased CKGR_MOR_Register; pragma Volatile_Full_Access (CKGR_MOR); ... end record with Volatile; with object as so: PMC_Periph : aliased PMC_Peripheral with Import, Address => PMC_Base; and the write respects the Volatile_Full_Access *as it writes each component separately to the register*! This fails, in this case, because the PMC hardware requires each write to this register to be accompanied by a valid value of the KEY field. The attached aggregate_assignment.zip contains Ada source, and the 10.1.0 and 11.0.1 versions of the arm-eabi cortex-m3 assembler output by -S. I've tried compiling the source in aggregate_assignment.zip with the x86_64-apple-darwin compiler, and the same bug seems to be present. NOTE, this bug is also present in GNAT CE 2020.