summaryrefslogtreecommitdiff
path: root/perl.h
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2021-06-21 15:36:05 +1000
committerNicholas Clark <nick@ccl4.org>2021-06-24 08:32:21 +0000
commit9302e8db483378404025d881979158d1eb6edc05 (patch)
tree8164978274747aba931e458b21fb7b5b9ddd1d18 /perl.h
parent76c45124d0ab3bf21d907620b12d64864fabc0df (diff)
downloadperl-9302e8db483378404025d881979158d1eb6edc05.tar.gz
ensure types of PL_nan and PL_inf are consistent
Different types for a variable across compilation units can in theory cause undefined behavior. In this case I think it's unlikely to cause an issue, but LTO builds also (correctly) complain about the type mismatch, so ensure they match.
Diffstat (limited to 'perl.h')
-rw-r--r--perl.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/perl.h b/perl.h
index 6d771e2340..6c3cb6d669 100644
--- a/perl.h
+++ b/perl.h
@@ -7974,8 +7974,25 @@ GCC_DIAG_RESTORE_DECL;
#else
+/* The declarations here need to match the initializations done above,
+ since a mismatch across compilation units causes undefined
+ behavior. It also prevents warnings from LTO builds.
+*/
+# if !defined(USE_QUADMATH) && \
+ (NVSIZE == LONG_DOUBLESIZE && defined(LONGDBLINFBYTES) || \
+ NVSIZE == DOUBLESIZE && defined(DOUBLEINFBYTES))
+INFNAN_U8_NV_DECL PL_inf;
+# else
INFNAN_NV_U8_DECL PL_inf;
+# endif
+
+# if !defined(USE_QUADMATH) && \
+ (NVSIZE == LONG_DOUBLESIZE && defined(LONGDBLNANBYTES) || \
+ NVSIZE == DOUBLESIZE && defined(DOUBLENANBYTES))
+INFNAN_U8_NV_DECL PL_nan;
+# else
INFNAN_NV_U8_DECL PL_nan;
+# endif
#endif