8000 unix/main: Make static variable that's potentially clobbered by longjmp. · micropython/micropython@9c9bfe1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c9bfe1

Browse files
maribudpgeorge
authored andcommitted
unix/main: Make static variable that's potentially clobbered by longjmp.
This fixes `error: variable 'subpkg_tried' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]` when compiling on ppc64le and aarch64 (and possibly other architectures/toolchains).
1 parent 2ac09c2 commit 9c9bfe1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ports/unix/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,12 @@ MP_NOINLINE int main_(int argc, char **argv) {
596596

597597
mp_obj_t mod;
598598
nlr_buf_t nlr;
599-
bool subpkg_tried = false;
599+
600+
// Allocating subpkg_tried on the stack can lead to compiler warnings about this
601+
// variable being clobbered when nlr is implemented using setjmp/longjmp. Its
602+
// value must be preserved across calls to setjmp/longjmp.
603+
static bool subpkg_tried;
604+
subpkg_tried = false;
600605

601606
reimport:
602607
if (nlr_push(&nlr) == 0) {

0 commit comments

Comments
 (0)
0