This is the usual problem of volatile accesses not preserved under (heavy) optimization. In Ada, we can put pragma Volatile on components of composite types without putting it on the enclosing type itself, but this doesn't really work when you're starting to optimize. Mostly gigi changes, but this plugs a hole in type_internals_preclude_sra_p which already tests TREE_THIS_VOLATILE on fields of record and union types but doesn't perform the equivalent test for array types. Tested on i586-suse-linux, applied on mainline, as obvious for the SRA bits. 2011-06-18 Eric Botcazou * tree-sra.c (type_internals_preclude_sra_p) : Return true if the element type is volatile. ada/ * gcc-interface/decl.c (gnat_to_gnu_component_type): Use GNAT_TYPE local variable throughout. Remove useless call to Base_Type. (gnat_to_gnu_field): Use GNAT_FIELD_TYPE local variable throughout. Take it also into account for the volatileness of the field. Set the TREE_SIDE_EFFECTS flag as well in this case. Reorder some warnings. 2011-06-18 Eric Botcazou * gnat.dg/volatile6.adb: New test. * gnat.dg/volatile7.adb: Likewise. * gnat.dg/volatile8.adb: Likewise. * gnat.dg/volatile9.adb: Likewise. -- Eric Botcazou