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

            Bug ID: 106064
           Summary: Wrong code comparing two global zero-sized arrays
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acoplan at gcc dot gnu.org
  Target Milestone: ---

For the following C code:

int a[0] = {};
int b[0] = {};
int f(void)
{
    return a != b;
}
int g(void)
{
    return (__UINTPTR_TYPE__)a != (__UINTPTR_TYPE__)b;
}

on AArch64 at -O2, we generate:

f:
        mov     w0, 1
        ret
g:
        mov     w0, 0
        ret

so f and g get optimized in contradictory ways. At least one of them must be
wrong.

Reply via email to