[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Skip initial expansion of valid array reference tokens in un
From: |
Koichi Murase |
Subject: |
Re: [PATCH] Skip initial expansion of valid array reference tokens in unset |
Date: |
Tue, 20 Apr 2021 10:35:15 +0900 |
2021年4月20日(火) 9:14 konsolebox <konsolebox@gmail.com>:
> On Tue, Apr 20, 2021 at 2:08 AM Koichi Murase <myoga.murase@gmail.com> wrote:
> > AFAIK `1 << 31' causes undefined behavior when int is 32-bit signed
> > integer. Instead, I think you may write `(int)(1u << 31)' for
> > conforming C compilers. `u << 31' is defined for unsigned integers,
> > and the conversion between signed and unsigned integers is defined to
> > be made by mod 2^{32} (when int is 32 bits).
>
> Not sure how this should be done right so I decided to just change
> 'flags' to unsigned int.
>
> - int flags; /* Flags associated with this word. */
> + unsigned int flags; /* Flags associated with this word. */
Yeah, right. I haven't checked the type of `flags'. We also need to
make it unsigned if we want to use bit 31.
In addition, you need to change `1 << 31' to `1u << 31'. The literal
`1' has the type `(signed) int'. One needs to use `1u'---the literal
of the type `unsigned int'.
--
Koichi