This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
- From: Ian Lance Taylor <iant at google dot com>
- To: Robert Dewar <dewar at adacore dot com>
- Cc: Paul Eggert <eggert at CS dot UCLA dot EDU>, autoconf-patches at gnu dot org, bug-gnulib at gnu dot org, gcc at gcc dot gnu dot org
- Date: 24 Mar 2007 11:43:49 -0700
- Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
- References: <200612300047.kBU0lFwk014817@localhost.localdomain> <87bqlmkui3.fsf@penguin.cs.ucla.edu> <m33b3v5swl.fsf@localhost.localdomain> <4604BB5F.7050706@adacore.com>
Robert Dewar <dewar@adacore.com> writes:
> Ian Lance Taylor wrote:
>
> > The new option -fstrict-overflow tells gcc that it can assume the
> > strict signed overflow semantics prescribed by the language standard.
> > This option is enabled by default at -O2 and higher. Using
> > -fno-strict-overflow will tell gcc that it can not assume that signed
> > overflow is undefined behaviour. The general effect of using this
> > option will be that signed overflow will become implementation
> > defined. This will disable a number of generally harmless
> > optimizations, but will not have the same effect as -fwrapv.
>
> Can you share the implementation definition (implementation defined
> generally means that the implementation must define what it does).
> This seems awfully vague.
You're right, I shouldn't have said "implementation defined."
What will happen with -fno-strict-overflow is whatever the processor
ISA happens to do when a signed arithmetic operation overflows. For
ordinary machines it will just wrap.
It is intentionally vague. If you need non-vague semantics, you
should use -fwrapv. -fno-strict-overflow is intended to provide the
vague semantics which C compilers have historically provided, in
support of existing code. -fstrict-overflow provides the reasonably
precise semantics of the language standard. The options are generally
analogous to -fstrict-aliasing and -fno-strict-aliasing.
Ian