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

--- Comment #3 from resence at parsoma dot net ---
It's not only the null pointer check per se though?

Re-add a stdio.h import for convenience, and it still vacillates whether or not
that address is NULL or not:

BAR2: 0x7f25d843173c
BAR3: 0x7f25d843173c
BAR4: 5
BAR5: 5
BAR2: 0x7f25d843173c
BAR3: 0x7f25d843173c
BAR4: 5
BAR5: 5
BAR2: 0x7f25d843173c
BAR3: 0x7f25d843173c
BAR4: 5
BAR5: 5

when using:
static int *nimErrorFlag(void) {
  /* With this, no always-false warning */
  /* printf("BAR1: %p\n", (void*)&nimInErrorMode__system_u4299); */

  if (((&nimInErrorMode__system_u4299) == (void *)0)) {
    write(1, "Always-false comparison is true\n", 32);
    printf("FOO: %p\n", (void*)&nimInErrorMode__system_u4299);
  }

  int *result = (&nimInErrorMode__system_u4299);
  printf("BAR2: %p\n", (void*)&nimInErrorMode__system_u4299);
  printf("BAR3: %p\n", (void*)result);
  printf("BAR4: %d\n", nimInErrorMode__system_u4299);
  printf("BAR5: %d\n", *result);

  return result;
}

Which still holds if one ensures that nimInErrorMode__system_u4299 is defined
and initialized in m.c:
__thread int nimInErrorMode__system_u4299 = 5;

Reply via email to