https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100409
--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Richard Biener from comment #7) > Jason, any idea? diff --git a/gcc/cp/except.c b/gcc/cp/except.c index a8cea53cf91..cbc94dff790 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1050,7 +1050,7 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, void * /*data*/) if (concept_check_p (fn)) return NULL_TREE; tree type = TREE_TYPE (fn); - gcc_assert (INDIRECT_TYPE_P (type)); + gcc_assert (INDIRECT_TYPE_P (type) || type == unknown_type_node); type = TREE_TYPE (type); STRIP_NOPS (fn); @@ -1073,7 +1073,7 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, void * /*data*/) to evaluate the noexcept-specifier's operand here, but that could cause instantiations that would fail. */ } - if (!TYPE_NOTHROW_P (type)) + if (type == unknown_type_node || !TYPE_NOTHROW_P (type)) return fn; } fixes all but the ICE for g++.dg/warn/noeffect4.C where we end up with an invalid CALL_EXPR: arg:0 <sizeof_expr 0x7ffff66ce940 type <integer_type 0x7ffff65617e0 long unsigned int> readonly arg:0 <call_expr 0x7ffff6550738 type <integer_type 0x7ffff65615e8 int> side-effects tree_6 fn <component_ref 0x7ffff66cf300 type <method_type 0x7ffff66a5f18> also notice how sizeof() doesn't have side-effects but the call has. I suppose that's somehow an "unevaluated" sizeof() expression we don't expect to hit expr_noexcept_p? OTOH noexcept(sizeof(foo())) might be "valid"? Changing the assert to if (INDIRECT_TYPE_P (type)) conditionalizing the use of 'type' beyond of course works. Aka diff --git a/gcc/cp/except.c b/gcc/cp/except.c index a8cea53cf91..623b83b8dc2 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1050,8 +1050,6 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, void * /*data*/) if (concept_check_p (fn)) return NULL_TREE; tree type = TREE_TYPE (fn); - gcc_assert (INDIRECT_TYPE_P (type)); - type = TREE_TYPE (type); STRIP_NOPS (fn); if (TREE_CODE (fn) == ADDR_EXPR) @@ -1073,7 +1071,8 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, void * /*data*/) to evaluate the noexcept-specifier's operand here, but that could cause instantiations that would fail. */ } - if (!TYPE_NOTHROW_P (type)) + if (!INDIRECT_TYPE_P (type) + || !TYPE_NOTHROW_P (TREE_TYPE (type))) return fn; } which leaves us with FAIL: g++.dg/warn/noeffect4.C -std=gnu++98 (test for warnings, line 84) FAIL: g++.dg/warn/noeffect4.C -std=gnu++14 (test for warnings, line 84) FAIL: g++.dg/warn/noeffect4.C -std=gnu++17 (test for warnings, line 84) FAIL: g++.dg/warn/noeffect4.C -std=gnu++2a (test for warnings, line 84) not diagnosing sizeof (x++); // { dg-warning "no effect" } not sure what should happen to the x++ side-effect (throwing).