From: Ivan Maidanski Date: Tue, 23 Oct 2012 03:45:51 +0000 (+0400) Subject: Fix GC_clear_stack by declaring 'dummy' local array as volatile X-Git-Tag: gc7_4_0~182 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a04a05d963bffa3130362d98f8d94daaf8c28378;p=gc Fix GC_clear_stack by declaring 'dummy' local array as volatile * misc.c (GC_clear_stack): Declare "dummy" local array as volatile to prevent optimizing it out by compiler; add cast of "dummy" to void* (to un-volatile the pointer) in BZERO call (only if THREADS). --- diff --git a/misc.c b/misc.c index c886d717..196ec7e7 100644 --- a/misc.c +++ b/misc.c @@ -321,7 +321,7 @@ GC_API void * GC_CALL GC_clear_stack(void *arg) { ptr_t sp = GC_approx_sp(); /* Hotter than actual sp */ # ifdef THREADS - word dummy[SMALL_CLEAR_SIZE]; + word volatile dummy[SMALL_CLEAR_SIZE]; static unsigned random_no = 0; /* Should be more random than it is ... */ /* Used to occasionally clear a bigger */ @@ -353,7 +353,7 @@ GC_API void * GC_CALL GC_clear_stack(void *arg) /* implementations of GC_clear_stack_inner. */ return GC_clear_stack_inner(arg, limit); } else { - BZERO(dummy, SMALL_CLEAR_SIZE*sizeof(word)); + BZERO((void *)dummy, SMALL_CLEAR_SIZE*sizeof(word)); return arg; } # else