Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Disable -Wsometimes-uninitialized warnings in the 9.2 branch.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 13 Dec 2021 06:28:13 +0000 (01:28 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 13 Dec 2021 06:28:13 +0000 (01:28 -0500)
In 9.2, we didn't yet teach the compiler that elog(ERROR) doesn't
return, which means that the compiler's opinion about whether
variable dereferences are reachable isn't worth much.  Back-patching
the commits that fixed that seems unduly invasive, so instead silence
related complaints with a big hammer.

-Wsometimes-uninitialized is a clang-ism; gcc seems to spell
this warning option differently.  However, I do not observe
any such compiler warnings in 9.2 with gcc 11.2.1, so for now
we needn't do anything for gcc.

Discussion: https://postgr.es/m/d0316012-ece7-7b7e-2d36-9c38cb77cb3b@enterprisedb.com

configure
configure.in

index 4c5629d53af051f6d17f9b2f52a847dd4f2e32e1..f5a3031979c58355e6458c1328d4b83aea040d74 100755 (executable)
--- a/configure
+++ b/configure
@@ -4670,6 +4670,73 @@ fi
   if test -n "$NOT_THE_CFLAGS"; then
     CFLAGS="$CFLAGS -Wno-stringop-truncation"
   fi
+  # Similarly disable sometimes-uninitialized warnings, because in this
+  # branch we have not taught the compiler that elog(ERROR) doesn't return,
+  # so that the compiler's opinion about this isn't worth much.
+  NOT_THE_CFLAGS=""
+  { $as_echo "$as_me:$LINENO: checking whether $CC supports -Wsometimes-uninitialized" >&5
+$as_echo_n "checking whether $CC supports -Wsometimes-uninitialized... " >&6; }
+if test "${pgac_cv_prog_cc_cflags__Wsometimes_uninitialized+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  pgac_save_CFLAGS=$CFLAGS
+CFLAGS="$pgac_save_CFLAGS -Wsometimes-uninitialized"
+ac_save_c_werror_flag=$ac_c_werror_flag
+ac_c_werror_flag=yes
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+    test -z "$ac_c_werror_flag" ||
+    test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  pgac_cv_prog_cc_cflags__Wsometimes_uninitialized=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+   pgac_cv_prog_cc_cflags__Wsometimes_uninitialized=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_c_werror_flag=$ac_save_c_werror_flag
+CFLAGS="$pgac_save_CFLAGS"
+fi
+{ $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wsometimes_uninitialized" >&5
+$as_echo "$pgac_cv_prog_cc_cflags__Wsometimes_uninitialized" >&6; }
+if test x"$pgac_cv_prog_cc_cflags__Wsometimes_uninitialized" = x"yes"; then
+  NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wsometimes-uninitialized"
+fi
+
+  if test -n "$NOT_THE_CFLAGS"; then
+    CFLAGS="$CFLAGS -Wno-sometimes-uninitialized"
+  fi
 elif test "$ICC" = yes; then
   # Intel's compiler has a bug/misoptimization in checking for
   # division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.
index 3314fd98a1539f766544b8ca8beff20c690bac61..e98e8c005666017909b7e776586deae8ec3c2841 100644 (file)
@@ -453,6 +453,14 @@ if test "$GCC" = yes -a "$ICC" = no; then
   if test -n "$NOT_THE_CFLAGS"; then
     CFLAGS="$CFLAGS -Wno-stringop-truncation"
   fi
+  # Similarly disable sometimes-uninitialized warnings, because in this
+  # branch we have not taught the compiler that elog(ERROR) doesn't return,
+  # so that the compiler's opinion about this isn't worth much.
+  NOT_THE_CFLAGS=""
+  PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wsometimes-uninitialized])
+  if test -n "$NOT_THE_CFLAGS"; then
+    CFLAGS="$CFLAGS -Wno-sometimes-uninitialized"
+  fi
 elif test "$ICC" = yes; then
   # Intel's compiler has a bug/misoptimization in checking for
   # division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.