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 <a.gatti@frob.it>
This commit is contained in:
Alessandro Gatti 2023-11-03 21:27:24 +01:00 committed by Damien George
parent 594c4229b7
commit 44527ada5f

View File

@ -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) {