From 44527ada5f120f5f131bcd759e86e4e5323555aa Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Fri, 3 Nov 2023 21:27:24 +0100 Subject: [PATCH] unix/main: Fix GCC builds for RISC-V 64 bits. This contains a workaround to silence a possibly incorrect warning when building the Unix port with GCC targeting RISC-V 64 bits. Fixes issue #12838. Signed-off-by: Alessandro Gatti --- ports/unix/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ports/unix/main.c b/ports/unix/main.c index 79d1e88ad..d9ee6eec4 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -562,7 +562,12 @@ MP_NOINLINE int main_(int argc, char **argv) { // First entry is empty. We've already added an empty entry to sys.path, so skip it. ++path; } - bool path_remaining = *path; + // GCC targeting RISC-V 64 reports a warning about `path_remaining` being clobbered by + // either setjmp or vfork if that variable it is allocated on the stack. This may + // probably be a compiler error as it occurs on a few recent GCC releases (up to 14.1.0) + // but LLVM doesn't report any warnings. + static bool path_remaining; + path_remaining = *path; while (path_remaining) { char *path_entry_end = strchr(path, PATHLIST_SEP_CHAR); if (path_entry_end == NULL) {