Closed
Description
The following code reports inconsistent results for __has_unique_object_representations
:
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: #69241 (comment)
Godbolt: https://gcc.godbolt.org/z/Pb9ze7YxM