Skip to content

Commit 416e3e3

Browse files
committed
Use -Wno-format-truncation and -Wno-stringop-truncation, if available.
gcc 8 has started emitting some warnings that are largely useless for our purposes, particularly since they complain about code following the project-standard coding convention that path names are assumed to be shorter than MAXPGPATH. Even if we make the effort to remove that assumption in some future release, the changes wouldn't get back-patched. Hence, just suppress these warnings, on compilers that have these switches. Backpatch to all supported branches. Discussion: https://postgr.es/m/1524563856.26306.9.camel@gunduz.org
1 parent 8c92485 commit 416e3e3

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

configure

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4833,6 +4833,7 @@ fi
48334833
# We want to suppress clang's unhelpful unused-command-line-argument warnings
48344834
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
48354835
# test for the positive form and if that works, add the negative form
4836+
NOT_THE_CFLAGS=""
48364837
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wunused-command-line-argument" >&5
48374838
$as_echo_n "checking whether $CC supports -Wunused-command-line-argument... " >&6; }
48384839
if ${pgac_cv_prog_cc_cflags__Wunused_command_line_argument+:} false; then :
@@ -4871,6 +4872,85 @@ fi
48714872
if test -n "$NOT_THE_CFLAGS"; then
48724873
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
48734874
fi
4875+
# Similarly disable useless truncation warnings from gcc 8+
4876+
NOT_THE_CFLAGS=""
4877+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wformat-truncation" >&5
4878+
$as_echo_n "checking whether $CC supports -Wformat-truncation... " >&6; }
4879+
if ${pgac_cv_prog_cc_cflags__Wformat_truncation+:} false; then :
4880+
$as_echo_n "(cached) " >&6
4881+
else
4882+
pgac_save_CFLAGS=$CFLAGS
4883+
CFLAGS="$pgac_save_CFLAGS -Wformat-truncation"
4884+
ac_save_c_werror_flag=$ac_c_werror_flag
4885+
ac_c_werror_flag=yes
4886+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4887+
/* end confdefs.h. */
4888+
4889+
int
4890+
main ()
4891+
{
4892+
4893+
;
4894+
return 0;
4895+
}
4896+
_ACEOF
4897+
if ac_fn_c_try_compile "$LINENO"; then :
4898+
pgac_cv_prog_cc_cflags__Wformat_truncation=yes
4899+
else
4900+
pgac_cv_prog_cc_cflags__Wformat_truncation=no
4901+
fi
4902+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4903+
ac_c_werror_flag=$ac_save_c_werror_flag
4904+
CFLAGS="$pgac_save_CFLAGS"
4905+
fi
4906+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_cflags__Wformat_truncation" >&5
4907+
$as_echo "$pgac_cv_prog_cc_cflags__Wformat_truncation" >&6; }
4908+
if test x"$pgac_cv_prog_cc_cflags__Wformat_truncation" = x"yes"; then
4909+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wformat-truncation"
4910+
fi
4911+
4912+
if test -n "$NOT_THE_CFLAGS"; then
4913+
CFLAGS="$CFLAGS -Wno-format-truncation"
4914+
fi
4915+
NOT_THE_CFLAGS=""
4916+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wstringop-truncation" >&5
4917+
$as_echo_n "checking whether $CC supports -Wstringop-truncation... " >&6; }
4918+
if ${pgac_cv_prog_cc_cflags__Wstringop_truncation+:} false; then :
4919+
$as_echo_n "(cached) " >&6
4920+
else
4921+
pgac_save_CFLAGS=$CFLAGS
4922+
CFLAGS="$pgac_save_CFLAGS -Wstringop-truncation"
4923+
ac_save_c_werror_flag=$ac_c_werror_flag
4924+
ac_c_werror_flag=yes
4925+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4926+
/* end confdefs.h. */
4927+
4928+
int
4929+
main ()
4930+
{
4931+
4932+
;
4933+
return 0;
4934+
}
4935+
_ACEOF
4936+
if ac_fn_c_try_compile "$LINENO"; then :
4937+
pgac_cv_prog_cc_cflags__Wstringop_truncation=yes
4938+
else
4939+
pgac_cv_prog_cc_cflags__Wstringop_truncation=no
4940+
fi
4941+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4942+
ac_c_werror_flag=$ac_save_c_werror_flag
4943+
CFLAGS="$pgac_save_CFLAGS"
4944+
fi
4945+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_cflags__Wstringop_truncation" >&5
4946+
$as_echo "$pgac_cv_prog_cc_cflags__Wstringop_truncation" >&6; }
4947+
if test x"$pgac_cv_prog_cc_cflags__Wstringop_truncation" = x"yes"; then
4948+
NOT_THE_CFLAGS="${NOT_THE_CFLAGS} -Wstringop-truncation"
4949+
fi
4950+
4951+
if test -n "$NOT_THE_CFLAGS"; then
4952+
CFLAGS="$CFLAGS -Wno-stringop-truncation"
4953+
fi
48744954
elif test "$ICC" = yes; then
48754955
# Intel's compiler has a bug/misoptimization in checking for
48764956
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

configure.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,22 @@ if test "$GCC" = yes -a "$ICC" = no; then
468468
# We want to suppress clang's unhelpful unused-command-line-argument warnings
469469
# but gcc won't complain about unrecognized -Wno-foo switches, so we have to
470470
# test for the positive form and if that works, add the negative form
471+
NOT_THE_CFLAGS=""
471472
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
472473
if test -n "$NOT_THE_CFLAGS"; then
473474
CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
474475
fi
476+
# Similarly disable useless truncation warnings from gcc 8+
477+
NOT_THE_CFLAGS=""
478+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation])
479+
if test -n "$NOT_THE_CFLAGS"; then
480+
CFLAGS="$CFLAGS -Wno-format-truncation"
481+
fi
482+
NOT_THE_CFLAGS=""
483+
PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wstringop-truncation])
484+
if test -n "$NOT_THE_CFLAGS"; then
485+
CFLAGS="$CFLAGS -Wno-stringop-truncation"
486+
fi
475487
elif test "$ICC" = yes; then
476488
# Intel's compiler has a bug/misoptimization in checking for
477489
# division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.

0 commit comments

Comments
 (0)