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] | |
This patch removes an old range check optimization which incorrectly assumes that the type of an arbitrary expression can always fit in the target type of a conversion. ------------ -- Source -- ------------ -- main.adb with Interfaces; use Interfaces; procedure Main is subtype Small_Positive is Integer_16 range 1 .. Integer_16'Last; type Target_Typ is array (Small_Positive range <>) of Boolean; pragma Convention (C, Target_Typ); subtype Large_Positive is Integer_32 range 1 .. 60_000; type Expr_Typ is array (Large_Positive range <>) of Boolean; type Expr_Typ_Ptr is access Expr_Typ; Expr : constant Expr_Typ := (1 .. 60_000 => True); Expr_Ptr : constant Expr_Typ_Ptr := new Expr_Typ'(Expr); Target : constant Target_Typ := Target_Typ (Expr_Ptr.all); begin null; end Main; ---------------------------- -- Compilation and output -- ---------------------------- $ gnatmake -q main.adb $ ./main.adb raised CONSTRAINT_ERROR : main.adb:16 range check failed Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Hristian Kirtchev <kirtchev@adacore.com> * checks.adb (Discrete_Range_Cond): Do not try to optimize on the assumption that the type of an expression can always fit in the target type of a conversion.
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] |