From: Sergei Trofimovich <siarh...@google.com> r12-1804 ("cp: add support for per-location warning groups.") among other things removed warning suppression from a few places including ptrmemfuncs.
Currently ptrmemfuncs don't have valid BINFO attached which causes ICEs in access checks: crash_signal gcc/toplev.c:328 perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, int, access_failure_info*) gcc/cp/semantics.c:490 finish_non_static_data_member(tree_node*, tree_node*, tree_node*) gcc/cp/semantics.c:2208 ... The change suppresses warnings again until we provide BINFOs for ptrmemfuncs. PR c++/101219 gcc/cp/ChangeLog: * typeck.c (build_ptrmemfunc_access_expr): Suppress all warnings to avoid ICE. gcc/testsuite/ChangeLog: * g++.dg/torture/pr101219.C: New test. --- gcc/cp/typeck.c | 6 +++++- gcc/testsuite/g++.dg/torture/pr101219.C | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr101219.C diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a483e1f988d..aa91fd21c7b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3326,7 +3326,11 @@ build_ptrmemfunc_access_expr (tree ptrmem, tree member_name) member = DECL_CHAIN (member)) if (DECL_NAME (member) == member_name) break; - return build_simple_component_ref (ptrmem, member); + tree r = build_simple_component_ref (ptrmem, member); + /* Suppress warning to avoid exposing missing BINFO for ptrmem + synthetic structs: PR101219. */ + suppress_warning(r); + return r; } /* Given an expression PTR for a pointer, return an expression diff --git a/gcc/testsuite/g++.dg/torture/pr101219.C b/gcc/testsuite/g++.dg/torture/pr101219.C new file mode 100644 index 00000000000..c8d30448187 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr101219.C @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wall" } */ +struct S { void m(); }; + +template <int> bool f() { + /* In PR101219 gcc used to ICE in warning code. */ + void (S::*mp)(); + + return &S::m == mp; +} -- 2.32.0