1-- { dg-do run }
2-- { dg-options "-O2 -fno-inline" }
3
4procedure Opt2 is
5   function Get return String is
6   begin
7      return "[]";
8   end Get;
9
10   Message : String := Get;
11
12   F, L : Integer;
13begin
14   for J in Message'Range loop
15      if Message (J) = '[' then
16         F := J;
17      elsif Message (J) = ']' then
18         L := J;
19         exit;
20      end if;
21   end loop;
22
23   declare
24      M : String :=
25         Message (Message'First .. F) & Message (L .. Message'Last);
26   begin
27      if M /= "[]" then
28        raise Program_Error;
29      end if;
30   end;
31end;
32