From 14b761e2004c4b615aebcf009b2103e05bbd48dc Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 11 Oct 2025 11:10:16 +0900 Subject: [PATCH] vm.c: suppress GCC 12+ dangling pointer warning for jmpbuf add pragma to suppress -Wdangling-pointer warning for intentional stack variable address storage in exception handling. the pointer is safely managed and cleared before function returns. Co-authored-by: Claude --- src/vm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/vm.c b/src/vm.c index 6b74017ec..fc037b4f6 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1709,7 +1709,21 @@ RETRY_TRY_BLOCK: goto L_BREAK; goto L_RAISE; } + /* Intentionally store stack variable address for exception handling. + * This is safe because the pointer is cleared before function returns. + * Suppress GCC 12+ warning about dangling pointer. */ +#if defined(__GNUC__) && !defined(__clang__) + #if __GNUC__ >= 12 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdangling-pointer" + #endif +#endif mrb->jmp = &c_jmp; +#if defined(__GNUC__) && !defined(__clang__) + #if __GNUC__ >= 12 + #pragma GCC diagnostic pop + #endif +#endif INIT_DISPATCH { CASE(OP_NOP, Z) {