summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2020-07-08 09:58:48 +0900
committerYusuke Endoh <mame@ruby-lang.org>2020-07-08 09:58:48 +0900
commitecfc09d053dc4bc9d413d94cd10b64aa05e4015b (patch)
treede8af2de3f091ed4da29562f0f26b5b5108e1e27 /gc.c
parentb06a4dc6f1fbef12ff7b4d57e7b5f12fd1f6cb5b (diff)
gc.c: Cast int literal "1" to bits_t
... because shifting by more than 31 bits has undefined behavior (depending upon platform). Coverity Scan found this issue.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index d1af8ba577..1e3b6c279d 100644
--- a/gc.c
+++ b/gc.c
@@ -4199,7 +4199,7 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_
/* create guard : fill 1 out-of-range */
bits[BITMAP_INDEX(p)] |= BITMAP_BIT(p)-1;
- bits[BITMAP_INDEX(p) + sweep_page->total_slots / BITS_BITLENGTH] |= ~((1 << ((NUM_IN_PAGE(p) + sweep_page->total_slots) % BITS_BITLENGTH)) - 1);
+ bits[BITMAP_INDEX(p) + sweep_page->total_slots / BITS_BITLENGTH] |= ~(((bits_t)1 << ((NUM_IN_PAGE(p) + sweep_page->total_slots) % BITS_BITLENGTH)) - 1);
for (i=0; i < HEAP_PAGE_BITMAP_LIMIT; i++) {
bitset = ~bits[i];