===================================================================
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
+-- Copyright (C) 1992-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -5521,10 +5521,14 @@
return;
end if;
- -- Ditto if the prefix is an explicit dereference whose designated
- -- type is unconstrained.
+ -- Ditto if prefix is simply an unconstrained array. We used
+ -- to think this case was OK, if the prefix was not an explicit
+ -- dereference, but we have now seen a case where this is not
+ -- true, so it is safer to just suppress the optimization in this
+ -- case. The back end is getting better at eliminating redundant
+ -- checks in any case, so the loss won't be important.
- elsif Nkind (Prefix (P)) = N_Explicit_Dereference
+ elsif Is_Array_Type (Atyp)
and then not Is_Constrained (Atyp)
then
Activate_Range_Check (N);