Skip to content

Commit 65c0c68

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 65c0c68

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Zend/zend_operators.h

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

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

3346
#include "zend_portability.h"

0 commit comments

Comments
 (0)