@@ -310,18 +310,19 @@ fi])# PGAC_C_BUILTIN_CONSTANT_P
310
310
# and define HAVE__BUILTIN_OP_OVERFLOW if so.
311
311
#
312
312
# Check for the most complicated case, 64 bit multiplication, as a
313
- # proxy for all of the operations. Use volatile variables to avoid the
314
- # compiler computing result at compile time, even though the runtime
315
- # might not supply operation. Have to link to be sure to recognize a
316
- # missing __builtin_mul_overflow .
313
+ # proxy for all of the operations. To detect the case where the compiler
314
+ # knows the function but library support is missing, we must link not just
315
+ # compile, and store the results in global variables so the compiler doesn't
316
+ # optimize away the call .
317
317
AC_DEFUN ( [ PGAC_C_BUILTIN_OP_OVERFLOW] ,
318
318
[ AC_CACHE_CHECK ( for __builtin_mul_overflow , pgac_cv__builtin_op_overflow ,
319
- [ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ ] ,
320
- [ PG_INT64_TYPE a = 1;
319
+ [ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [
320
+ PG_INT64_TYPE a = 1;
321
321
PG_INT64_TYPE b = 1;
322
322
PG_INT64_TYPE result;
323
- __builtin_mul_overflow(*(volatile PG_INT64_TYPE *) a, *(volatile PG_INT64_TYPE *) b, &result);]
324
- ) ] ,
323
+ int oflo;
324
+ ] ,
325
+ [ oflo = __builtin_mul_overflow(a, b, &result);] ) ] ,
325
326
[ pgac_cv__builtin_op_overflow=yes] ,
326
327
[ pgac_cv__builtin_op_overflow=no] ) ] )
327
328
if test x"$pgac_cv__builtin_op_overflow" = xyes ; then
0 commit comments