PR tree-optimization/86415 - strlen() not folded for substrings within constant arrays
[official-gcc.git] / gcc / testsuite / gnat.dg / array_bounds_test2.adb
blob43e1ed3ced0c334b8946097bc94f94654faf4f6e
1 -- { dg-do run }
3 with Ada.Unchecked_Deallocation;
5 procedure Array_Bounds_Test2 is
7 type String_Ptr_T is access String;
8 procedure Free is new Ada.Unchecked_Deallocation (String, String_Ptr_T);
9 String_Data : String_Ptr_T := new String'("Hello World");
11 function Peek return String_Ptr_T is
12 begin
13 return String_Data;
14 end Peek;
16 begin
17 declare
18 Corrupted_String : String := Peek.all;
19 begin
20 Free(String_Data);
21 if Corrupted_String'First /= 1 then
22 raise Program_Error;
23 end if;
24 end;
25 end;