This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Optimization missed


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]