From 23027db35101a00780ea9f264ad6f354c33b56f6 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 17 Feb 2016 10:54:31 +0300 Subject: [PATCH] Fix 'statement unreachable' compiler warning in GC_mark_from * mark.c (GC_mark_from): Initialize 'limit' local variable unconditionally; add static assertion on GC_DS_TAGS (to check that it corresponds to number of switch cases); remove switch default (as it cannot happen). --- mark.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mark.c b/mark.c index 128617e2..131efd94 100644 --- a/mark.c +++ b/mark.c @@ -607,9 +607,9 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack, mse *mark_stack_limit) { signed_word credit = HBLKSIZE; /* Remaining credit for marking work */ - ptr_t current_p; /* Pointer to current candidate ptr. */ - word current; /* Candidate pointer. */ - ptr_t limit; /* (Incl) limit of current candidate range. */ + ptr_t current_p; /* Pointer to current candidate ptr. */ + word current; /* Candidate pointer. */ + ptr_t limit = 0; /* (Incl) limit of current candidate range. */ word descr; ptr_t greatest_ha = GC_greatest_plausible_heap_addr; ptr_t least_ha = GC_least_plausible_heap_addr; @@ -636,6 +636,7 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack, if (descr & ((~(WORDS_TO_BYTES(SPLIT_RANGE_WORDS) - 1)) | GC_DS_TAGS)) { word tag = descr & GC_DS_TAGS; + GC_STATIC_ASSERT(GC_DS_TAGS == 0x3); switch(tag) { case GC_DS_LENGTH: /* Large length. */ @@ -767,9 +768,6 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack, continue; } goto retry; - default: - limit = 0; /* initialized to prevent warning. */ - ABORT_RET("GC_mark_from: bad state"); } } else /* Small object with length descriptor */ { mark_stack_top--; -- 2.40.0