From af00c4da32c855867936409d920582cc773f0d01 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 31 Aug 2018 19:14:18 +0300 Subject: [PATCH] Eliminate 'potential unsafe sign check of a bitwise operation' code defect * mark.c [!OS2] (GC_mark_from): Cast mark_stack_top-mark_stack to word first, and cast bitwise OR operation result to signed_word, so that not to apply bitwise OR operation to the value of ptrdiff_t. --- mark.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mark.c b/mark.c index ee6dc83..1159e3d 100644 --- a/mark.c +++ b/mark.c @@ -650,7 +650,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack, # ifdef OS2 /* Use untweaked version to circumvent compiler problem */ while ((word)mark_stack_top >= (word)mark_stack && credit >= 0) # else - while ((((ptr_t)mark_stack_top - (ptr_t)mark_stack) | credit) >= 0) + while ((signed_word)(((word)mark_stack_top - (word)mark_stack) + | (word)credit) >= 0) # endif { current_p = mark_stack_top -> mse_start; -- 2.7.4