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]
Other format: [Raw text]

[Bug other/43449] New: sbitmap is broken if gcc is built with -m32 on a 64-bit machine.


We found a problem in sbitmap.c:


bool
sbitmap_range_empty_p (const_sbitmap bmap, unsigned int start, unsigned int n)
{
  unsigned int i = start / SBITMAP_ELT_BITS;
  SBITMAP_ELT_TYPE elm;
...
      /* The bits are totally contained in a single element.  */
      if (shift + n < SBITMAP_ELT_BITS)
        elm &= ((1 << n) - 1);

depending on configuration, SBITMAP_ELT_TYPE can be wider than the int type. 
The masking above will mistakenly strip off top bits from elm.  The correct
code should be written as:

      /* The bits are totally contained in a single element.  */
      if (shift + n < SBITMAP_ELT_BITS)
        elm &= (((SBITMAP_ELF_BITS) 1 << n) - 1);

The same problem appears in another location of the same function.  The broken
code is in both 4.4.0 and trunk.


-- 
           Summary: sbitmap is broken if gcc is built with -m32 on a 64-bit
                    machine.
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dougkwan at google dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu (with -m32)
GCC target triplet: arm-none-eabi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43449


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