1<<31 upsets ubsan

This commit is contained in:
Michael Davidsaver
2023-03-10 10:57:35 +00:00
parent f99a1cb0f3
commit d3f93746a8
4 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -85,7 +85,7 @@ set_first_derives(void)
k = 0;
}
if (cword & (1 << k))
if (cword & (1u << k))
{
rp = derives[j];
while ((rule = *rp++) >= 0)
@@ -152,7 +152,7 @@ closure(short int *nucleus, int n)
{
for (i = 0; i < BITS_PER_WORD; ++i)
{
if (word & (1 << i))
if (word & (1u << i))
{
itemno = rrhs[ruleno+i];
while (csp < csend && *csp < itemno)
+2 -2
View File
@@ -26,7 +26,7 @@ transitive_closure(unsigned int *R, int n)
while (rowj < relend)
{
if (*ccol & (1 << i))
if (*ccol & (1u << i))
{
rp = rowi;
rend = rowj + rowsize;
@@ -68,7 +68,7 @@ reflexive_transitive_closure(unsigned int *R, int n)
rp = R;
while (rp < relend)
{
*rp |= (1 << i);
*rp |= (1u << i);
if (++i >= BITS_PER_WORD)
{
i = 0;