From 5feb29ea039e0f140cb4f07b81a0671d543c26f9 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 17 Sep 2024 07:51:34 +0100 Subject: [PATCH] Fix ubsan build on freebsd regarding float. due to the system header machine/ieeefp.h proceeding to a bitshift operation. close GH-15935 --- Zend/zend_operators.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index e98956239ec3b..ce8b7f5e0a2a7 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -27,7 +27,20 @@ #include #ifdef HAVE_IEEEFP_H -#include +/** + * On FreeBSD with ubsan/clang we get the following: + * `/usr/include/machine/ieeefp.h:161:17: runtime error: left shift of negative value -1` + * `SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/machine/ieeefp.h:161:17` + * ... + * `_newcw |= (~_m << FP_MSKS_OFF) & FP_MSKS_FLD;` +**/ +# if __has_feature(undefined_behavior_sanitizer) && defined(__FreeBSD__) && defined(__clang__) +# pragma clang attribute push (__attribute__((no_sanitize("undefined"))), apply_to=function) +# endif +# include +# if __has_feature(undefined_behavior_sanitizer) && defined(__FreeBSD__) && defined(__clang__) +# pragma clang attribute pop +# endif #endif #include "zend_portability.h"