Optimization missed

Alexandre Oliva oliva@dcc.unicamp.br
Wed Jun 30 23:07:00 GMT 1999


On Jun 21, 1999, Jason Schonberg <schon@mips.com> wrote:

>  unsigned A;
>  if (A > -5) return 12;

> It's nice to see that the compiler warns about the comparison
> between signed and unsigned.  Why does the generated code not
> dispose of the comparison all together?

I can't say for C, but in C++, if either operand of a comparison is
unsigned, the other shall be converted to unsigned, so you'd actually
get:

   if (A > (unsigned)-5) return 12;

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists



More information about the Gcc-bugs mailing list