#define relptr_is_null(rp) \
((rp).relptr_off == 0)
+/* We use this inline to avoid double eval of "val" in relptr_store */
+static inline Size
+relptr_store_eval(char *base, char *val)
+{
+ if (val == NULL)
+ return 0;
+ else
+ {
+ Assert(val > base);
+ return val - base;
+ }
+}
+
#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P
#define relptr_store(base, rp, val) \
(AssertVariableIsOfTypeMacro(base, char *), \
AssertVariableIsOfTypeMacro(val, __typeof__((rp).relptr_type)), \
- (rp).relptr_off = ((val) == NULL ? 0 : ((char *) (val)) - (base)))
+ (rp).relptr_off = relptr_store_eval(base, (char *) (val)))
#else
/*
* If we don't have __builtin_types_compatible_p, assume we might not have
*/
#define relptr_store(base, rp, val) \
(AssertVariableIsOfTypeMacro(base, char *), \
- (rp).relptr_off = ((val) == NULL ? 0 : ((char *) (val)) - (base)))
+ (rp).relptr_off = relptr_store_eval(base, (char *) (val)))
#endif
#define relptr_copy(rp1, rp2) \