Issue 95311
Summary [clang] __has_unique_object_representations gives inconsistent answer based on instantiation order
Labels clang
Assignees
Reporter ldionne
    The following code reports inconsistent results for `__has_unique_object_representations`:

```c++
template <int>
class Foo {
  int x;
};

static_assert(__has_unique_object_representations(Foo<0>[]));
static_assert(__has_unique_object_representations(Foo<0>[][3]));
static_assert(__has_unique_object_representations(Foo<0>));
```

The key here is that if you assert `__has_unique_object_representations(Foo<0>)` **first**, then everything works. So somehow asking for `__has_unique_object_representations(Foo<0>)` must cause something to be instantiated or stored in the AST and that changes the result of a subsequent `__has_unique_object_representations(Foo<0>[])` query (notice the array).

This bug was extracted from this comment: https://github.com/llvm/llvm-project/pull/69241#issuecomment-2163612863

Godbolt: https://gcc.godbolt.org/z/Pb9ze7YxM
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to