On Tue, Oct 20, 2020 at 06:39:39PM +0200, Rainer Orth wrote: > Hi Tobias, > > > On 10/19/20 8:21 PM, Jakub Jelinek via Gcc-patches wrote: > > > >> On Mon, Oct 19, 2020 at 06:57:49PM +0100, Kwok Cheung Yeung wrote: > >>> --- a/libgomp/target.c > >>> +++ b/libgomp/target.c > > ... > >> Otherwise LGTM. > > > > Unfortunately, the committed patch > > (r11-4121-g1bfc07d150790fae93184a79a7cce897655cb37b) > > causes build errors. > > the patch also breaks bootstrap on both i386-pc-solaris2.11 and > sparc-sun-solaris2.11: > > /vol/gcc/src/hg/master/local/libgomp/env.c: In function 'initialize_env': > /vol/gcc/src/hg/master/local/libgomp/env.c:414:16: error: 'new_offload' may > be used uninitialized in this function [-Werror=maybe-uninitialized] > 414 | *offload = new_offload; > | ~~~~~~~~~^~~~~~~~~~~~~ > /vol/gcc/src/hg/master/local/libgomp/env.c:384:30: note: 'new_offload' was > declared here > 384 | enum gomp_target_offload_t new_offload; > | ^~~~~~~~~~~
I can't reproduce that, but I fail to see why we need two separate variables, one with actual value and one tracking if the value is valid. So I'd go with: 2020-10-20 Jakub Jelinek <ja...@redhat.com> * env.c (parse_target_offload): Change new_offload var type to int, preinitialize to -1, remove found var and test new_offload != -1 instead of found. --- libgomp/env.c.jj 2020-10-20 14:37:36.593968443 +0200 +++ libgomp/env.c 2020-10-20 18:43:00.338389023 +0200 @@ -380,8 +380,7 @@ static void parse_target_offload (const char *name, enum gomp_target_offload_t *offload) { const char *env; - bool found = false; - enum gomp_target_offload_t new_offload; + int new_offload = -1; env = getenv (name); if (env == NULL) @@ -392,24 +391,21 @@ parse_target_offload (const char *name, if (strncasecmp (env, "default", 7) == 0) { env += 7; - found = true; new_offload = GOMP_TARGET_OFFLOAD_DEFAULT; } else if (strncasecmp (env, "mandatory", 9) == 0) { env += 9; - found = true; new_offload = GOMP_TARGET_OFFLOAD_MANDATORY; } else if (strncasecmp (env, "disabled", 8) == 0) { env += 8; - found = true; new_offload = GOMP_TARGET_OFFLOAD_DISABLED; } while (isspace ((unsigned char) *env)) ++env; - if (found && *env == '\0') + if (new_offload != -1 && *env == '\0') { *offload = new_offload; return; Jakub