This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 3.3 / i386 / -O2 question
- From: Steven Bosscher <stevenb at suse dot de>
- To: Luca Benini <lbenini at csr dot unibo dot it>
- Cc: Dave Korn <dk at artimi dot com>, 'Gerald Pfeifer' <gerald at pfeifer dot com>,'Beschorner Daniel' <Daniel dot Beschorner at facton dot com>, gcc at gcc dot gnu dot org,gcc-help at gcc dot gnu dot org
- Date: Wed, 17 Nov 2004 12:53:53 +0100 (CET)
- Subject: Re: gcc 3.3 / i386 / -O2 question
- Organization: SuSE Linux AG
- References: <NUTMEG0wzGDCvPeSHvn00000800@NUTMEG.CAM.ARTIMI.COM> <419B3277.9060209@csr.unibo.it>
On Nov 17, 2004 12:13 PM, Luca Benini <lbenini@csr.unibo.it> wrote:
> Dave Korn wrote:
> > Excuse me for butting in, but I don't understand what makes
> > anyone think this code _ought_ to produce the same results at
> > different -O levels[*]. The C
> > language spec is explicit that this is undefined behaviour.
>
> As every software that do data-processing you need it will
> reproduce the
> same behavior with any not-altering-semantic-option.
Hah, but there you are. Define "non-altering-semantic-option"
for something that according to the standard does not *have*
semantics.
> If the code is syntattical garbage ===> compiler don't compile it
Right.
> if the code is semantical garbage ===> same compiler must generate the
> same output (in .s or in .o) ==> you must obtain the same result.
Wrong, IMHO.
Remember, "Undefined behavior" is not the same thing as "Unspecified
behavior". In the latter case, perhaps you're right. Unspecified
behavior should be consistent independent of the compiler options
(and this behavior should be documented). But for undefined behavior
you shouldn't expect anything.
Gr.
Steven