aboutsummaryrefslogtreecommitdiffstats
path: root/cont.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2022-06-13 14:03:57 +0900
committerYusuke Endoh <mame@ruby-lang.org>2022-06-13 15:18:28 +0900
commit5060c9d852be4b99d773ec1d94e0ec08ac4299b7 (patch)
tree8213eb7b2e88d77a0b1f8eded3efac08e3c1fcda /cont.c
parent425a46131a029390cd693242e621f6632c76cc42 (diff)
downloadruby-5060c9d852be4b99d773ec1d94e0ec08ac4299b7.tar.gz
cont.c: prevent a warning of GCC 12.1
... by assigning a dummy value to the allocated stack. http://rubyci.s3.amazonaws.com/arch/ruby-master/log/20220613T000004Z.log.html.gz ``` cont.c: In function ‘cont_restore_0.constprop’: cont.c:1489:28: warning: ‘*sp’ may be used uninitialized [-Wmaybe-uninitialized] 1489 | space[0] = *sp; | ^~~ ``` Also it adds some comments about the hack of dummy stack allocation.
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/cont.c b/cont.c
index 38f5ceca4e..36f47d9ee6 100644
--- a/cont.c
+++ b/cont.c
@@ -1486,6 +1486,10 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
if (&space[0] > end) {
# ifdef HAVE_ALLOCA
volatile VALUE *sp = ALLOCA_N(VALUE, &space[0] - end);
+ // We need to make sure that the stack pointer is moved,
+ // but some compilers may remove the allocation by optimization.
+ // We hope that the following read/write will prevent such an optimization.
+ *sp = Qfalse;
space[0] = *sp;
# else
cont_restore_0(cont, &space[0]);