From: alvin <alvin@iplink.net>
To: axp-list@redhat.com
Subject: Re: gcc 2.96 optimization bug on RedHat7.0/alpha
Date: Wed, 18 Apr 2001 13:07:24 -0400 [thread overview]
Message-ID: <3ADDC9CC.25847588@iplink.net> (raw)
In-Reply-To: 4DAF89CD261ED011A47B0000C0F973BF016FB619@norge.is.sal.ksu.edu
"Hoover, Tony" wrote:
>
> Granted, however a compile time warning that your source will generate
> "_undefined_ behavior" should not be out of the question.
> ---------------------------------------------------------------------------
> Tony Hoover, Network Administrator
> KSU - Salina, College of Technology
> mailto:hoover@sal.ksu.edu
>
> "Don't Blend in..."
> ----------------------------------------------------------------------------
>
> > ----------
> > From: David Woodhouse[SMTP:dwmw2@infradead.org]
> > Reply To: axp-list@redhat.com
> > Sent: Wednesday, April 18, 2001 11:17 AM
> > To: axp-list@redhat.com
> > Subject: Re: gcc 2.96 optimization bug on RedHat7.0/alpha
> >
> >
> > gatgul@voicenet.com said:
> > > BTW your opinion about the code posted is broken, is also ur opinion.
> > > It is perfectly correct IMHO . I guess it just does not live up to
> > > some one else's arbitrary standard.
> >
> > The 'arbitrary standard' to which you refer is known as ISO C99.
> >
> > If you desire a compiler which lives up to other standards, that's fine -
> > just don't report bugs against gcc. Do you see people reporting gcc to be
> > buggy because it doesn't compile FORTRAN code to produce the results you
> > expect?
> >
> >
> > > I'm sorry that u believe this but i believe that the results from
> > > -O0 == -O1 == -O2 == -O3 == -O4
> > > should all be the same. If any one of them failes to be equal, then
> > > the compiler failed to produce the correct code to derive the correct
> > > results.
> >
> > That is an interesting opinion. The rest of the world, however, accepts
> > the
> > fact that according to the specifications of the C language, certain code
> > has _undefined_ behaviour. If the compiler encounters such code, it's
> > perfectly entitled to send insulting mail to your boss and sleep with your
> > wife. It's certainly not required to do the same thing each time.
Then the compiler should allways print out a line that is somthing like
"you code may not work as you expect(you have been warned)"
Just a little try at humor. But on a more serious note. C as a language
has a number of issues about order of evaluation of expressions and what
will happen if you have side effects because of expression evaluation. I
missed part of the early part of the thread but at this point it seems
to be a discussion about what a compiler will do compared to what you
might expect.
Concider
int x = 1;
int y = 2;
int fval = 4;
int f(int val)
{
return fval/=val;
}
t = f(x) + f(y);
is t = 4 + 2
or is t = 2 + 2
since "+" is commutitive it is legitimate to evaluate either f(x) or
f(y) first but because of side effects you will get different results. A
compiler can pick any order of evaluation so long as the operator
precedance is kept.
Now this is an extreem example but it is possible to find more subtile
examples of this in everyday code.
--
Alvin Starr || voice: (416)585-9971
Interlink Connectivity || fax: (416)585-9974
alvin@iplink.net ||
next prev parent reply other threads:[~2001-04-18 17:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-18 16:22 gcc 2.96 optimization bug on RedHat7.0/alpha Hoover, Tony
2001-04-18 16:55 ` David Woodhouse
2001-04-18 17:07 ` alvin [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-04-18 1:46 Uncle George
2001-04-18 0:04 ` Christopher C. Chimelis
2001-04-18 3:41 ` Matt Wilson
2001-04-18 4:32 ` Brad Lucier
2001-04-18 15:13 ` Uncle George
2001-04-18 13:40 ` Pawel Salek
2001-04-18 15:53 ` Uncle George
2001-04-18 14:03 ` David Woodhouse
2001-04-18 17:10 ` Uncle George
2001-04-18 15:40 ` Pawel Salek
2001-04-18 16:17 ` David Woodhouse
2001-04-18 16:46 ` Andrew A. Gill
2001-04-18 17:04 ` T. Daniel Crawford
2001-04-18 18:15 ` Nelson Brito
2001-04-18 18:38 ` jeff.sturm
2001-04-18 14:55 ` Michal Jaegermann
2001-04-18 22:18 ` Uncle George
2001-04-18 20:50 ` Chris Eleveld (Sector 7 Group)
2001-04-18 21:33 ` Michal Jaegermann
2001-04-18 23:09 ` P.TURLAIS
2001-04-19 0:28 ` Uncle George
2001-04-18 22:03 ` jeff.sturm
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox