1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Use -fwrapv in CFLAGS if we are using a version of gcc that accepts this flag.

This prevents compiler optimizations that assume overflow won't occur, which
breaks numerous overflow tests that we need to have working.  It is known
that gcc 4.3 causes problems and possible that 4.1 does.  Per my proposal
of some time ago and a recent report from Kris Jurka.

Backpatch as far as 8.0, which is as far as the patch conveniently goes.
7.x was pretty short of overflow tests anyway, so it may not matter there,
even assuming that anyone cares whether 7.x builds on recent gcc.
This commit is contained in:
Tom Lane
2008-03-10 21:50:40 +00:00
parent 8576a07843
commit 77f5afc306
2 changed files with 57 additions and 1 deletions

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.431.2.23 2008/02/24 05:22:22 tgl Exp $
dnl $PostgreSQL: pgsql/configure.in,v 1.431.2.24 2008/03/10 21:50:40 tgl Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
@ -278,6 +278,8 @@ choke me
# Disable strict-aliasing rules; needed for gcc 3.3+
PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
# Disable optimizations that assume no overflow; needed for gcc 4.3+
PGAC_PROG_CC_CFLAGS_OPT([-fwrapv])
elif test x"${CC}" = x"xlc"; then
# AIX xlc has to have strict aliasing turned off too
PGAC_PROG_CC_CFLAGS_OPT([-qnoansialias])