--- /dev/null
+-- { dg-do compile }\r
+-- { dg-options "-O" }\r
+\r
+with System, Ada.Unchecked_Conversion;\r
+with System.Storage_Elements; use System.Storage_Elements;\r
+\r
+procedure Loop_Address2 is\r
+\r
+ type Ptr is access all Integer;\r
+\r
+ function To_Ptr is new Ada.Unchecked_Conversion (System.Address, Ptr);\r
+\r
+ function F (BM : System.Address; I : Integer) return System.Address is\r
+ begin\r
+ return BM + Storage_Offset (4*I);\r
+ end;\r
+\r
+ B : Integer;\r
+ P : Ptr;\r
+\r
+begin\r
+ for I in 0 .. 2 loop\r
+ P := To_Ptr (F (B'Address, I));\r
+ P.all := 0;\r
+ end loop;\r
+end ;\r