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

            Bug ID: 115157
           Summary: incorrect TBAA for derived types involving enum types
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: muecker at gwdg dot de
  Target Milestone: ---

Another example where TBAA does not seem to work correctly similar to PR114959.
I guess here it should be easier to set TYPE_CANONICAL correctly in the FE, but
we have the same completion issues we also have in C23 with other tagged types.

https://godbolt.org/z/qcWxn9f6z

enum E { E1 = -1, E2 = 0, E3 = 1 };

typedef int A;
typedef enum E B;

_Static_assert(_Generic((A){ 0 }, B: 1), "");

void* foo(void* a, void *b, A *c, B *d)
{
        *(A**)a = c;
        *(B**)b = d;
        return *(A**)a;
}

int main()
{
        A *a, b, c;
        if (&c != (A*)foo(&a, &a, &b, &c))
                __builtin_abort();
}

Reply via email to