Skip to content

Commit cea3168

Browse files
committed
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
1 parent 4687738 commit cea3168

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

configure

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4670,6 +4670,73 @@ fi
46704670
if test -n "$NOT_THE_CFLAGS"; then
46714671
CFLAGS="$CFLAGS -Wno-stringop-truncation"
46724672
fi
4673+
# Similarly disable sometimes-uninitialized warnings, because in this
4674+
# branch we have not taught the compiler that elog(ERROR) doesn't return,
4675+
# so that the compiler's opinion about this isn't worth much.
4676+
NOT_THE_CFLAGS=""
4677+
{ $as_echo "$as_me:$LINENO: checking whether $CC supports -Wsometimes-uninitialized" >&5
4678+
$as_echo_n "checking whether $CC supports -Wsometimes-uninitialized... " >&6; }
4679+
if test "${pgac_cv_prog_cc_cflags__Wsometimes_uninitialized+set}" = set; then
4680+
$as_echo_n "(cached) " >&6
4681+
else
4682+
pgac_save_CFLAGS=$CFLAGS
4683+
CFLAGS="$pgac_save_CFLAGS -Wsometimes-uninitialized"
4684+
ac_save_c_werror_flag=$ac_c_werror_flag
4685+
ac_c_werror_flag=yes
4686+
cat >conftest.$ac_ext <<_ACEOF
4687+
/* confdefs.h. */
4688+
_ACEOF
4689+
cat confdefs.h >>conftest.$ac_ext
4690+
cat >>conftest.$ac_ext <<_ACEOF
4691+
/* end confdefs.h. */
4692+
4693+
int
4694+
main ()
4695+
{
4696+
4697+
;
4698+
return 0;
4699+
}
4700+
_ACEOF
4701+
rm -f conftest.$ac_objext
4702+
if { (ac_try="$ac_compile"
4703+
case "(($ac_try" in
4704+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4705+
*) ac_try_echo=$ac_try;;
4706+
esac
4707+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
4708+
$as_echo "$ac_try_echo") >&5
4709+
(eval "$ac_compile") 2>conftest.er1
4710+
ac_status=$?
4711+
grep -v '^ *+' conftest.er1 >conftest.err
4712+
rm -f conftest.er1
4713+
cat conftest.err >&5
4714+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
4715+
(exit $ac_status); } && {
4716+
test -z "$ac_c_werror_flag" ||
4717+
test ! -s conftest.err
4718+
} && test -s conftest.$ac_objext; then
4719+
pgac_cv_prog_cc_cflags__Wsometimes_uninitialized=yes
4720+
else
4721+
$as_echo "$as_me: failed program was:" >&5
4722+
sed 's/^/| /' conftest.$ac_ext >&5
4723+
4724+
pgac_cv_prog_cc_cflags__Wsometimes_uninitialized=no
4725+
fi
4726+
4727+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4728+
ac_c_werror_flag=$ac_save_c_werror_flag
4729+
CFLAGS="$pgac_save_CFLAGS"
4730+
fi
4731+
{ $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__Wsometimes_uninitialized" >&5
4732+
$as_echo "$pgac_cv_prog_cc_cflags__Wsometimes_uninitialized" >&6; }
4733+
if test x"$pgac_cv_prog_cc_cflags__Wsometimes_uninitialized" = x"yes"; then
4734+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wsometimes-uninitialized"
4735+
fi
4736+
4737+
if test -n "$NOT_THE_CFLAGS"; then
4738+
CFLAGS="$CFLAGS -Wno-sometimes-uninitialized"
4739+
fi
46734740
elif test "$ICC" = yes; then
46744741
# Intel's compiler has a bug/misoptimization in checking for
46754742
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

configure.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,14 @@ if test "$GCC" = yes -a "$ICC" = no; then
453453
if test -n "$NOT_THE_CFLAGS"; then
454454
CFLAGS="$CFLAGS -Wno-stringop-truncation"
455455
fi
456+
# Similarly disable sometimes-uninitialized warnings, because in this
457+
# branch we have not taught the compiler that elog(ERROR) doesn't return,
458+
# so that the compiler's opinion about this isn't worth much.
459+
NOT_THE_CFLAGS=""
460+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wsometimes-uninitialized])
461+
if test -n "$NOT_THE_CFLAGS"; then
462+
CFLAGS="$CFLAGS -Wno-sometimes-uninitialized"
463+
fi
456464
elif test "$ICC" = yes; then
457465
# Intel's compiler has a bug/misoptimization in checking for
458466
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

0 commit comments

Comments
 (0)