This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fix incorrect assignment to array with Component_Size clause


This change fixes a wrong translation of the assignment of an aggregate
made up of a single Others choice to an array whose nominal size of the
component type is the storage unit and which is subject to a Component_Size
clause that effectively bumps this size.

The compiler was generating a call to memset in this case, which filled
the gap between the nominal size and the component size with copies of
the single Others value instead of zero/sign-extending it appropriately.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

2017-12-15  Eric Botcazou  <ebotcazou@adacore.com>

	* exp_aggr.adb: Fix for QC04-027 (incorrect assignment to array
	with Component_Size clause):

	* exp_aggr.adb (Aggr_Assignment_OK_For_Backend): Use
	Component_Size of the innermost array instead of Esize of its
	component type to exclude inappropriate array types, including
	packed array types.

gcc/testsuite/

2017-12-15  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/component_size.adb: New testcase.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]