From: "alanwu (Alan Wu) via ruby-core" Date: 2025-11-03T04:25:48+00:00 Subject: [ruby-core:123657] [Ruby Bug#21659] rstring.h error: missing initializer for field ‘len’ of ‘struct RString’ [-Werror=missing-field-initializers] starting in ruby-3.3.10 Issue #21659 has been updated by alanwu (Alan Wu). Status changed from Feedback to Rejected `-Wmissing-field-initializers` is in `-Wextra`, not even in `-Wall`. From the [manual](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmissing-field-initializers) (emphasis mine) > Warn if a structure���s initializer has some fields missing. For example, the following code causes such a warning, because x.h is __implicitly zero__: > > struct s { int f, g, h; }; > struct s x = { 3, 4 }; All fields are initialized, just some are done implicitly. In fact, before the patch you point to, all fields were actually uninitialized; there is strictly more initialization happening now. The warning acts more like a lint if you want to conform to a certain coding style, and isn't a flag for some material problem that ends up in the compiled artifact. It's fine to use this warning in your code, but it's unreasonable to expect ruby to use the same style as you. You can toss in a `#pragma` around `#include "ruby.h"` to fix your build. In general, `-Werror` makes your build forward incompatible with future compilers because they release with new warnings all the time. ---------------------------------------- Bug #21659: rstring.h error: missing initializer for field ���len��� of ���struct RString��� [-Werror=missing-field-initializers] starting in ruby-3.3.10 https://bugs.ruby-lang.org/issues/21659#change-115039 * Author: wsfulton (William Fulton) * Status: Rejected * ruby -v: ruby 3.3.10 (2025-10-23 revision 343ea05002) [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- 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 ```c++ struct RString retval = {RBASIC_INIT}; ``` should have been changed to: ```c++ struct RString retval = {RBASIC_INIT, 0}; ``` in rstring.h as well as all in the actual Ruby code base. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/