Strangeness (maybe a bug?) in expmed.c: extract_bit_field_1()

Jeff Kenton jkenton@tilera.com
Thu Jun 23 15:17:00 GMT 2011


In expmed.c: extract_bit_field_1() I see the following:

       /* On big-endian machines, we count bits from the most significant.
          If the bit field insn does not, we must invert.  */
       if (BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN)
         xbitpos = unit - bitsize - xbitpos;

This produces a negative value for xbitpos for BIG_ENDIAN code, despite 
the fact that xbitpos is declared unsigned.  The code in alpha/alpha.md 
that it calls promptly converts the bit offset back to its original 
value, and I have to do the same for my own BIG_ENDIAN port.

This smells like a bug, although I suspect changing it would break 
existing ports.

Thoughts?

--jeff



More information about the Gcc-help mailing list