From 81bcd4e931c8a153b853f62a53c71951c6472322 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 15 Apr 2026 09:40:06 +0900 Subject: [PATCH] mruby-bigint: simplify MPZ_CTX_INIT with positional initializer Per gemini-code-assist review on #6791: replace member-by-member assignment with C89/C++98-style positional aggregate initialization, keeping the macro a single declaration and matching the existing pool_storage initializer style in the same macro. Co-authored-by: Claude --- mrbgems/mruby-bigint/core/bigint.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mrbgems/mruby-bigint/core/bigint.c b/mrbgems/mruby-bigint/core/bigint.c index 5b3be1f6e..b17c9712a 100644 --- a/mrbgems/mruby-bigint/core/bigint.c +++ b/mrbgems/mruby-bigint/core/bigint.c @@ -51,15 +51,14 @@ typedef struct mpz_context { } mpz_ctx_t; /* Convenience macros for context creation. - * Uses per-member assignment instead of a C99 compound literal with - * designated initializers so the file compiles as C++ on legacy - * toolchains (pre-C++20). */ + * Uses positional aggregate initialization instead of a C99 compound + * literal with designated initializers, so the file compiles as C++ + * on legacy toolchains (pre-C++20). Member order must match the + * mpz_context struct declaration above. */ #define MPZ_CTX_INIT(mrb_ptr, ctx, pool_ptr) \ mpz_pool_t pool ## _storage = {{0}};\ mpz_pool_t *pool_ptr = &pool ## _storage;\ - mpz_ctx_t ctx ## _struct; \ - ctx ## _struct.mrb = (mrb_ptr); \ - ctx ## _struct.pool = (pool_ptr); \ + mpz_ctx_t ctx ## _struct = { (mrb_ptr), (pool_ptr) }; \ mpz_ctx_t *ctx = &(ctx ## _struct); /* Access macros for readability */