ruby-changes:74394
From: Nobuyoshi <ko1@a...>
Date: Tue, 8 Nov 2022 16:13:57 +0900 (JST)
Subject: [ruby-changes:74394] 001606097b (master): Suppress false warning by a bug of gcc
https://git.ruby-lang.org/ruby.git/commit/?id=001606097b From 001606097b3239b84a5910e2f2bc814074cb6973 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 8 Nov 2022 15:06:15 +0900 Subject: Suppress false warning by a bug of gcc GCC [Bug 99578] seems triggered by calling `rb_reg_last_match` before `match_check(match)`, probably by `NIL_P(match)` in `rb_reg_nth_match`. [Bug 99578]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578 --- re.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/re.c b/re.c index c65e4a58eb..1b83148321 100644 --- a/re.c +++ b/re.c @@ -1066,12 +1066,13 @@ update_char_offset(VALUE match) https://github.com/ruby/ruby/blob/trunk/re.c#L1066 } } -static void +static VALUE match_check(VALUE match) { if (!RMATCH(match)->regexp) { rb_raise(rb_eTypeError, "uninitialized MatchData"); } + return match; } /* :nodoc: */ @@ -2268,16 +2269,16 @@ match_values_at(int argc, VALUE *argv, VALUE match) https://github.com/ruby/ruby/blob/trunk/re.c#L2269 static VALUE match_to_s(VALUE match) { - VALUE str = rb_reg_last_match(match); + VALUE str = rb_reg_last_match(match_check(match)); - match_check(match); if (NIL_P(str)) str = rb_str_new(0,0); return str; } static int match_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end, - int back_num, int *back_refs, OnigRegex regex, void *arg) { + int back_num, int *back_refs, OnigRegex regex, void *arg) +{ struct MEMO *memo = MEMO_CAST(arg); VALUE hash = memo->v1; VALUE match = memo->v2; -- cgit v1.2.3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/