Skip to content

improve __buitin_mul_overflow() checks #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")

CHECK_C_SOURCE_COMPILES(
"#include <sys/types.h>
"#include <stddef.h>
int main() { int a,b; size_t m; __builtin_mul_overflow(a,b,&m); return 0; }"
HAVE_BUILTIN_MUL_OVERFLOW
)
Expand Down
10 changes: 3 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,12 @@ PCRE2_VISIBILITY

AC_MSG_CHECKING([for __builtin_mul_overflow()])
AC_LANG_PUSH([C])
tmp_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <stddef.h>

int a, b;
size_t m;
]], [[__builtin_mul_overflow(a, b, &m)]])],
Expand All @@ -96,7 +93,6 @@ if test "$pcre2_cc_cv_builtin_mul_overflow" = yes; then
AC_DEFINE([HAVE_BUILTIN_MUL_OVERFLOW], 1,
[Define this if your compiler provides __builtin_mul_overflow()])
fi
CFLAGS=$tmp_CFLAGS
AC_LANG_POP([C])

# Check for Clang __attribute__((uninitialized)) feature
Expand Down