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 fortran/31964] ishftc fails with certain thrid argument



------- Comment #3 from jvdelisle at gcc dot gnu dot org  2007-05-17 01:49 -------
I think we have an off by one when setting mask.  I want to do some testing and
double check on all this.  Here is a patch:

Index: ishftc.c
===================================================================
*** ishftc.c    (revision 124756)
--- ishftc.c    (working copy)
*************** ishftc4 (GFC_INTEGER_4 i, GFC_INTEGER_4 
*** 45,51 ****
    if (shift == 0 || shift == size)
      return i;

!   mask = (~(GFC_INTEGER_4)0) << size;
    bits = i & ~mask;
    return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
  }
--- 45,51 ----
    if (shift == 0 || shift == size)
      return i;

!   mask = (~(GFC_INTEGER_4)0) << (size - 1);
    bits = i & ~mask;
    return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
  }
*************** ishftc8 (GFC_INTEGER_8 i, GFC_INTEGER_4 
*** 65,71 ****
    if (shift == 0 || shift == size)
      return i;

!   mask = (~(GFC_INTEGER_8)0) << size;
    bits = i & ~mask;
    return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
  }
--- 65,71 ----
    if (shift == 0 || shift == size)
      return i;

!   mask = (~(GFC_INTEGER_8)0) << (size - 1);
    bits = i & ~mask;
    return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
  }
*************** ishftc16 (GFC_INTEGER_16 i, GFC_INTEGER_
*** 86,92 ****
    if (shift == 0 || shift == size)
      return i;

!   mask = (~(GFC_INTEGER_16)0) << size;
    bits = i & ~mask;
    return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
  }
--- 86,92 ----
    if (shift == 0 || shift == size)
      return i;

!   mask = (~(GFC_INTEGER_16)0) << (size - 1);
    bits = i & ~mask;
    return (i & mask) | (bits >> (size - shift)) | ((i << shift) & ~mask);
  }


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jvdelisle at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-05-17 01:30:46         |2007-05-17 01:49:20
               date|                            |


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


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