Skip to content

Commit 97d24f6

Browse files
committed
Fix ubsan build on freebsd regarding float.
due to the system header machine/ieeefp.h proceeding to a bitshift operation.
1 parent b26e610 commit 97d24f6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Zend/zend_operators.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,19 @@
2727
#include <stddef.h>
2828

2929
#ifdef HAVE_IEEEFP_H
30-
#include <ieeefp.h>
30+
/// On FreeBSD with ubsan/clang we get the following:
31+
/// `/usr/include/machine/ieeefp.h:161:17: runtime error: left shift of negative value -1`
32+
/// `SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/machine/ieeefp.h:161:17`
33+
/// ...
34+
/// `_newcw |= (~_m << FP_MSKS_OFF) & FP_MSKS_FLD;`
35+
///
36+
# if __has_feature(undefined_behavior_sanitizer) && defined(__FreeBSD__) && defined(__clang__)
37+
# pragma clang attribute push (__attribute__((no_sanitize("undefined"))), apply_to=function)
38+
# endif
39+
# include <ieeefp.h>
40+
# if __has_feature(undefined_behavior_sanitizer) && defined(__FreeBSD__) && defined(__clang__)
41+
# pragma clang attribute pop
42+
# endif
3143
#endif
3244

3345
#include "zend_portability.h"

0 commit comments

Comments
 (0)