From 7d1011d3fa7226c47adf2914fb9035304f233cb2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 22 Oct 2024 15:08:29 +0900 Subject: Fix false warning by gcc 14 for aarch64 gcc 14 for aarch64 with `-O3` may emit a false positive warning for a pointer access of `RB_BUILTIN_TYPE` called from `RB_TYPE_P`. `Qfalse` shouldn't get there because of `RB_SPECIAL_CONST_P`, but the optimizer seems to ignore this condition in some cases (`ASSUME` just before the access doesn't seem to have any effect either). Only by reversing the order in `RB_SPECIAL_CONST_P` to compare with 0 first does the warning seem to go away. --- include/ruby/internal/special_consts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/ruby/internal') diff --git a/include/ruby/internal/special_consts.h b/include/ruby/internal/special_consts.h index 05d1087c88..1e2636da48 100644 --- a/include/ruby/internal/special_consts.h +++ b/include/ruby/internal/special_consts.h @@ -326,7 +326,7 @@ RBIMPL_ATTR_ARTIFICIAL() static inline bool RB_SPECIAL_CONST_P(VALUE obj) { - return RB_IMMEDIATE_P(obj) || obj == RUBY_Qfalse; + return (obj == RUBY_Qfalse) || RB_IMMEDIATE_P(obj); } RBIMPL_ATTR_CONST() -- cgit v1.2.3