https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99859
--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #12)
> And in #c9 you're right that it could be embedded in CONSTRUCTORs too.
Wonder if cp_walk_tree &arg to find the ADDR_EXPR of heap var addresses and
ctx->global->object address would be enough.
Counter example I was thinking about would be:
constexpr int foo(auto x) { return ++*x->p; }
struct S {
int a = 0;
constexpr S() {
struct R { int* p; };
R b{&a};
R c{&a};
foo(&b);
foo(&c);
}
};
constexpr S s = S();
static_assert (s.a == 2);
but in that case we handle it correctly already as the address of the automatic
vars is already non-constant.