1-- { dg-do run }
2
3with Unchecked_Conversion;
4
5procedure Unchecked_Convert10 is
6
7  subtype Unsigned_Type is Integer range 2_034 .. 2_164;
8
9  subtype Signed_Type is Integer range -2048 .. 2047;
10
11  function To_Signed_Type is
12     new Unchecked_Conversion (Source => Unsigned_Type, Target => Signed_Type);
13
14  function To_Unsigned_Type is
15     new Unchecked_Conversion (Source => Signed_Type, Target => Unsigned_Type);
16
17  Data : Unsigned_Type;
18  Temp : Signed_Type;
19
20begin
21
22  Data := 2100;
23  Temp := To_Signed_Type (Data);
24  if Temp /= -1996 then
25    raise Program_Error;
26  end if;
27  Data := To_Unsigned_Type (Temp);
28  if Data /= 2100 then
29    raise Program_Error;
30  end if;
31
32  Data := 2047;
33  Temp := To_Signed_Type (Data);
34  if Temp /= 2047 then
35    raise Program_Error;
36  end if;
37  Data := To_Unsigned_Type (Temp);
38  if Data /= 2047 then
39    raise Program_Error;
40  end if;
41
42end;
43