Did shift of 32. Not allowed
authorceriel <none@none>
Wed, 2 Oct 1991 13:41:33 +0000 (13:41 +0000)
committerceriel <none@none>
Wed, 2 Oct 1991 13:41:33 +0000 (13:41 +0000)
lang/cem/cemcom.ansi/struct.c
lang/cem/cemcom/struct.c

index ebac4e4..ab84e87 100644 (file)
@@ -420,7 +420,8 @@ add_field(szp, fd, fdtpp, idf, stp)
                Sign extension could occur on some machines when shifting
                the mask to the left.
        */
-       fd->fd_mask = (1 << fd->fd_width) - 1;
+       if (fd->fd_width >= 8*sizeof(arith)) fd->fd_mask = -1;
+       else fd->fd_mask = (1L << fd->fd_width) - 1;
 
        if (options['r'])       /* adjust the field at the right        */
                fd->fd_shift = bits_declared - fd->fd_width;
index 813bb8a..de7f6af 100644 (file)
@@ -456,7 +456,8 @@ add_field(szp, fd, fdtpp, idf, stp)
                Sign extension could occur on some machines when shifting
                the mask to the left.
        */
-       fd->fd_mask = (1 << fd->fd_width) - 1;
+       if (fd->fd_width >= 8*sizeof(arith)) fd->fd_mask = -1;
+       else fd->fd_mask = (1L << fd->fd_width) - 1;
 
        if (options['r'])       /* adjust the field at the right        */
                fd->fd_shift = bits_declared - fd->fd_width;