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] Handle constraint error in vector when large index type


To compute the range of values in the generic actual Index_Type for a
vector, there is a series of compile-time tests to determine which of
Index_Type or Count_Type to use for intermediate values.

In the case of an Index_Type comprising a range of values larger than
in Count_Type, the number of values was computed using Index_Type, and
then converted to Count_Type. However, even though the computation of
the result does not overflow, the conversion of the result to type
Count_Type will fail when the value is greater than
Count_Type'Last. The solution is to first test whether the result is
less than Count_Type'Last, and only then convert the result.

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

2013-10-17  Matthew Heaney  <heaney@adacore.com>

	* a-convec.adb, a-coinve.adb, a-cobove.adb (Insert, Insert_Space):
	Inspect value range before converting type.

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]