Project

General

Profile

Actions

Bug #21659

closed

rstring.h error: missing initializer for field ‘len’ of ‘struct RString’ [-Werror=missing-field-initializers] starting in ruby-3.3.10

Bug #21659: rstring.h error: missing initializer for field ‘len’ of ‘struct RString’ [-Werror=missing-field-initializers] starting in ruby-3.3.10

Added by wsfulton (William Fulton) 1 day ago. Updated about 16 hours ago.

Status:
Feedback
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.10 (2025-10-23 revision 343ea05002) [x86_64-linux]
[ruby-core:123626]

Description

All extensions now have this error when using -Werror -Wmissing-field-initializers:

In file included from /home/runner/.rvm/rubies/ruby-3.3.10/include/ruby-3.3.0/ruby/internal/arithmetic/char.h:29,
                 from /home/runner/.rvm/rubies/ruby-3.3.10/include/ruby-3.3.0/ruby/internal/arithmetic.h:24,
                 from /home/runner/.rvm/rubies/ruby-3.3.10/include/ruby-3.3.0/ruby/ruby.h:28,
                 from /home/runner/.rvm/rubies/ruby-3.3.10/include/ruby-3.3.0/ruby.h:38,
                 from example_wrap.c:1008:
/home/runner/.rvm/rubies/ruby-3.3.10/include/ruby-3.3.0/ruby/internal/core/rstring.h: In function ‘rbimpl_rstring_getmem’:
/home/runner/.rvm/rubies/ruby-3.3.10/include/ruby-3.3.0/ruby/internal/core/rstring.h:398:16: error: missing initializer for field ‘len’ of ‘struct RString’ [-Werror=missing-field-initializers]
  398 |         struct RString retval = {RBASIC_INIT};
      |                ^~~~~~~
/home/runner/.rvm/rubies/ruby-3.3.10/include/ruby-3.3.0/ruby/internal/core/rstring.h:206:10: note: ‘len’ declared here
  206 |     long len;
      |          ^~~

Can you please test with warnings turned on as this now breaks all extensions that rely on Ruby.h being warning free.

Looks like it is due to commit https://github.com/ruby/ruby/commit/5a8d7642168f4ea0d9331fded3033c225bbc36c5 and expect that

        struct RString retval = {RBASIC_INIT};

should have been changed to:

        struct RString retval = {RBASIC_INIT, 0};

in rstring.h as well as all in the actual Ruby code base.

Updated by nobu (Nobuyoshi Nakada) about 23 hours ago Actions #1 [ruby-core:123628]

  • Status changed from Open to Feedback

In configure.ac, we add -Wno-missing-field-initializers explicitly if available.
Are you adding that -Werror -Wmissing-field-initializer by yourself?

Updated by wsfulton (William Fulton) about 17 hours ago Actions #2 [ruby-core:123633]

This happens when compiling an EXTENSION. We have always used -Wmissing-field-initializers in our extensions and now they are broken. New Ruby releases really MUST NOT introduce new warnings for extensions which have to include Ruby.h.

Updated by jeremyevans0 (Jeremy Evans) about 16 hours ago Actions #3 [ruby-core:123635]

wsfulton (William Fulton) wrote in #note-2:

This happens when compiling an EXTENSION. We have always used -Wmissing-field-initializers in our extensions and now they are broken. New Ruby releases really MUST NOT introduce new warnings for extensions which have to include Ruby.h.

New Ruby releases should not introduce errors in extensions. I think it is unreasonable to expect that they will not introduce warnings if you are explicitly configuring non-default warning flags. If you are combining non-default warning flags with -Werror, I think you are responsible for handling the issues that result from that, since it is your actions that are causing the errors. I realize this may have worked in the past for you, but that was by chance, it is not something that Ruby has officially or deliberately supported.

Actions

Also available in: PDF Atom