From 24a353f3e1d63a2d1f6b060b2efc7f86c6735c84 Mon Sep 17 00:00:00 2001 From: ceriel Date: Wed, 2 Oct 1991 13:41:33 +0000 Subject: [PATCH] Did shift of 32. Not allowed --- lang/cem/cemcom.ansi/struct.c | 3 ++- lang/cem/cemcom/struct.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lang/cem/cemcom.ansi/struct.c b/lang/cem/cemcom.ansi/struct.c index ebac4e40d..ab84e8766 100644 --- a/lang/cem/cemcom.ansi/struct.c +++ b/lang/cem/cemcom.ansi/struct.c @@ -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; diff --git a/lang/cem/cemcom/struct.c b/lang/cem/cemcom/struct.c index 813bb8a47..de7f6af4b 100644 --- a/lang/cem/cemcom/struct.c +++ b/lang/cem/cemcom/struct.c @@ -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;