[Ada] Prevent copying uninitialized array with address clause

Pierre-Marie de Rodat derodat@adacore.com
Fri Oct 23 08:26:40 GMT 2020


An object of a nominal unconstrained array type may be given a subtype
by initialization with an aggregate with specified bounds and box
initialization. The freezing of the object copies the aggregate into
the object, which propagates uninitialized values if the component type
has no default specified. This patch introduces a predicate to recognize
and optimize away such useless copies, when the object includes an
address clause.

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

gcc/ada/

	* freeze.adb (Is_Uninitialized_Aggregate): Recognize an array
	aggregate with box initialization, scalar components, and no
	component default values.
	(Freeze_Entity, Check_Address_Clause): Call it, and simplify
	freeze code for entity by removing useless assignment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 2623 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201023/014a2e8e/attachment-0001.bin>


More information about the Gcc-patches mailing list