Skip to content

Commit

Permalink
cont.c: prevent a warning of GCC 12.1
Browse files Browse the repository at this point in the history
... 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.
  • Loading branch information
mame committed Jun 13, 2022
1 parent 425a461 commit 5060c9d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cont.c
Expand Up @@ -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]);
Expand Down

0 comments on commit 5060c9d

Please sign in to comment.