ruby-changes:62495
From: Nobuyoshi <ko1@a...>
Date: Sat, 1 Aug 2020 15:17:12 +0900 (JST)
Subject: [ruby-changes:62495] b6e6807993 (master): Initialize memo pointer and use it consistently to silence gcc 7+
https://git.ruby-lang.org/ruby.git/commit/?id=b6e6807993 From b6e6807993c770c5d2e069d8741f5dadf0b38069 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 1 Aug 2020 14:48:04 +0900 Subject: Initialize memo pointer and use it consistently to silence gcc 7+ diff --git a/array.c b/array.c index 5c611fc..87e7fb3 100644 --- a/array.c +++ b/array.c @@ -6931,7 +6931,7 @@ flatten(VALUE ary, int level) https://github.com/ruby/ruby/blob/trunk/array.c#L6931 { long i; VALUE stack, result, tmp = 0, elt, vmemo; - st_table *memo; + st_table *memo = 0; st_data_t id; for (i = 0; i < RARRAY_LEN(ary); i++) { @@ -6974,7 +6974,7 @@ flatten(VALUE ary, int level) https://github.com/ruby/ruby/blob/trunk/array.c#L6974 } tmp = rb_check_array_type(elt); if (RBASIC(result)->klass) { - if (level < 0) { + if (memo) { RB_GC_GUARD(vmemo); st_clear(memo); } @@ -6984,7 +6984,7 @@ flatten(VALUE ary, int level) https://github.com/ruby/ruby/blob/trunk/array.c#L6984 rb_ary_push(result, elt); } else { - if (level < 0) { + if (memo) { id = (st_data_t)tmp; if (st_is_member(memo, id)) { st_clear(memo); @@ -7001,7 +7001,7 @@ flatten(VALUE ary, int level) https://github.com/ruby/ruby/blob/trunk/array.c#L7001 if (RARRAY_LEN(stack) == 0) { break; } - if (level < 0) { + if (memo) { id = (st_data_t)ary; st_delete(memo, &id, 0); } @@ -7010,7 +7010,7 @@ flatten(VALUE ary, int level) https://github.com/ruby/ruby/blob/trunk/array.c#L7010 ary = rb_ary_pop(stack); } - if (level < 0) { + if (memo) { st_clear(memo); } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/