(convert (plus:c @@0 @1)))
(if (INTEGRAL_TYPE_P (type)
&& TYPE_OVERFLOW_UNDEFINED (type)
+ /* For integer literals, using an intermediate unsigned type to avoid
+ an overflow at run time is counter-productive because it introduces
+ spurious overflows at compile time, in the form of TREE_OVERFLOW on
+ the result, which may be problematic in GENERIC for some front-ends:
+ (T)P - (T)(P + 4) -> (T)(-(U)4) -> (T)(4294967292) -> -4(OVF)
+ so we use the direct path for them. */
+ && TREE_CODE (@1) != INTEGER_CST
&& element_precision (type) <= element_precision (TREE_TYPE (@1)))
(with { tree utype = unsigned_type_for (type); }
(convert (negate (convert:utype @1))))
(convert (pointer_plus @@0 @1)))
(if (INTEGRAL_TYPE_P (type)
&& TYPE_OVERFLOW_UNDEFINED (type)
+ /* See above the rationale for this condition. */
+ && TREE_CODE (@1) != INTEGER_CST
&& element_precision (type) <= element_precision (TREE_TYPE (@1)))
(with { tree utype = unsigned_type_for (type); }
(convert (negate (convert:utype @1))))
--- /dev/null
+-- { dg-do compile }
+
+with System.Storage_Elements; use System.Storage_Elements;
+with System;
+
+package Storage_Offset1 is
+
+ type Rec is record
+ I1, I2 : Integer;
+ end record;
+
+ type Ptr is access all Rec;
+
+ R : Ptr := new Rec;
+
+ Offset : constant Storage_Offset := R.I1'Address - R.I2'Address;
+
+end Storage_Offset1;