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 <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-10-11 11:10:16 +09:00
parent 4499daf88e
commit 14b761e200
+14
View File
@@ -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) {