https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116741
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> --- I suppose we could do just: --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -8201,8 +8201,11 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, TREE_TYPE (op), TREE_TYPE (TREE_TYPE (sop)), TREE_TYPE (type)); tree obj = build_fold_indirect_ref (sop); - inform (DECL_SOURCE_LOCATION (obj), - "pointed-to object declared here"); + while (TREE_CODE (obj) == COMPONENT_REF) + obj = TREE_OPERAND (obj, 1); + if (DECL_P (obj)) + inform (DECL_SOURCE_LOCATION (obj), + "pointed-to object declared here"); } *non_constant_p = true; return t;