throw.h: avoid using static member in C++ struct; fix
The initialization causes linkage error with gcc (not clang), caused by
the following gcc bug:
MODIFY
include/mruby/throw.h
include/mruby/throw.h
@@ -52,14 +52,15 @@ typedef mrb_int mrb_jmpbuf_impl;
#endif
+#if defined(MRB_USE_CXX_EXCEPTION)
+extern mrb_int mrb_jmpbuf_id;
+#endif
+
struct mrb_jmpbuf {
mrb_jmpbuf_impl impl;
#if defined(MRB_USE_CXX_EXCEPTION)
- static mrb_int jmpbuf_id;
-# if defined(__cplusplus)
- mrb_jmpbuf() : impl(jmpbuf_id++) {}
-# endif
+ mrb_jmpbuf() : impl(mrb_jmpbuf_id++) {}
#endif
};

MODIFY
src/vm.c
src/vm.c
@@ -3127,5 +3127,5 @@ mrb_top_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int st
# if !defined(MRB_USE_CXX_ABI)
} /* end of extern "C" */
# endif
-mrb_int mrb_jmpbuf::jmpbuf_id = 0;
+mrb_int mrb_jmpbuf_id = 0;
#endif

throw.h: avoid using static member in C++ struct; fix #5846

The initialization causes linkage error with gcc (not clang), caused by
the following gcc bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86254