From 8c165a32b7cc4f2a147a37c920a96f1b09b2386d Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 30 Dec 2018 21:29:07 -0700 Subject: regen/warnings.pl: Fix undefined C behavior This fixes compiler warnings "performing pointer arithmetic on a null pointer has undefined behavior" There are several ways to fix this. This one was suggested by Tomasz Konojacki++. Instead of trying to point to address 1 and 2, two variables are created, and we point to them. const is cast away. --- warnings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'warnings.h') diff --git a/warnings.h b/warnings.h index e0c12ed403..58f52272de 100644 --- a/warnings.h +++ b/warnings.h @@ -18,8 +18,8 @@ #define G_WARN_ALL_MASK (G_WARN_ALL_ON|G_WARN_ALL_OFF) #define pWARN_STD NULL -#define pWARN_ALL (((STRLEN*)0)+1) /* use warnings 'all' */ -#define pWARN_NONE (((STRLEN*)0)+2) /* no warnings 'all' */ +#define pWARN_ALL (STRLEN *) &PL_WARN_ALL /* use warnings 'all' */ +#define pWARN_NONE (STRLEN *) &PL_WARN_NONE /* no warnings 'all' */ #define specialWARN(x) ((x) == pWARN_STD || (x) == pWARN_ALL || \ (x) == pWARN_NONE) -- cgit v1.2.1