The compiler reports an spurious error processing a derived type of a non-tagged record type that has discriminants, pragma Unchecked_Union and pragma Convention C. After this patch the following test compiles silently. procedure Conversion is type small_array is array (0 .. 2) of Integer; type big_array is array (0 .. 3) of Integer; type small_record is record field1 : aliased Integer := 0; field2 : aliased small_array := (0, 0, 0); end record; type big_record is record field1 : aliased Integer := 0; field2 : aliased big_array := (0, 0, 0, 0); end record; type myUnion (discr : Integer := 0) is record case discr is when 0 => record1 : aliased small_record; when others => record2 : aliased big_record; end case; end record; type UU_myUnion3 (discr : Integer := 0) is new myUnion (discr); -- Test pragma Unchecked_Union (UU_myUnion3); pragma Convention (C, UU_myUnion3); procedure Convert (A : in UU_myUnion3; B : out UU_myUnion3); pragma Import (C, Convert); begin null; end Conversion; Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ 2017-09-29 Javier Miranda * sem_ch3.adb (Replace_Components): Update references to discriminants located in variant parts inherited from the parent type. gcc/testsuite/ 2017-09-29 Javier Miranda * gnat.dg/unchecked_union2.adb: New testcase.