From d5080f6e8b77364483ff6727b1065e45e180f05d Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 22 Feb 2024 16:11:24 -0800 Subject: [PATCH] Fix -Wsign-compare on String#initialize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../string.c:1886:57: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘long int’ [-Wsign-compare] 1886 | if (STR_EMBED_P(str)) RUBY_ASSERT(osize <= str_embed_capa(str)); | ^~ --- string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/string.c b/string.c index a4ba85f42e..f8a64fca13 100644 --- a/string.c +++ b/string.c @@ -1883,7 +1883,7 @@ rb_str_init(int argc, VALUE *argv, VALUE str) const char *const old_ptr = RSTRING_PTR(str); const size_t osize = RSTRING_LEN(str) + TERM_LEN(str); char *new_ptr = ALLOC_N(char, size); - if (STR_EMBED_P(str)) RUBY_ASSERT(osize <= str_embed_capa(str)); + if (STR_EMBED_P(str)) RUBY_ASSERT((long)osize <= str_embed_capa(str)); memcpy(new_ptr, old_ptr, osize < size ? osize : size); FL_UNSET_RAW(str, STR_SHARED|STR_NOFREE); RSTRING(str)->as.heap.ptr = new_ptr;