1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Disable -Wsometimes-uninitialized warnings in the 9.2 branch.

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
This commit is contained in:
Tom Lane
2021-12-13 01:28:13 -05:00
parent 468773837b
commit cea316881f
2 changed files with 75 additions and 0 deletions

67
configure vendored
View File

@ -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.

View 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.