From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3C9CC3858025; Tue, 19 Apr 2022 13:08:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C9CC3858025 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105244] [9/10/11/12 Regression] ICE in implicitly_declare_fn, at cp/method.cc:3114 Date: Tue, 19 Apr 2022 13:08:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Apr 2022 13:08:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105244 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek --- template struct S { static T max (); }; template struct V { double a =3D S::max[0] (); }; template V<> foo () { return {}; } int main () { V<> b =3D foo (); } What happens is that synthesized_method_walk with diag =3D false calls get_= nsdmi with tf_none, and much deeper there is pointer_int_sum which has: if (complain && warn_pointer_arith) pedwarn (loc, OPT_Wpointer_arith, "pointer to a function used in arithmetic"); else if (!complain) return error_mark_node; So, if get_nsdmi were called with tf_warning_or_error, we'd pedwarn on it, = but we are quite and just return error_mark_node from get_nsdmi in that case. So, we end up with raises =3D error_mark_node and enter: /* Can happen, e.g., in C++98 mode for an ill-formed non-static d= ata member initializer (c++/89914). Also, in C++98, we might have failed to deduce RAISES, so try again but complain this time. = */ if (cxx_dialect < cxx11) synthesized_method_walk (type, kind, const_p, &raises, nullptr, nullptr, nullptr, /*diag=3D*/true, &inherited_ctor, inherited_parms); /* We should have seen an error at this point. */ gcc_assert (seen_error ()); and ICE, because at this point whether we pedwarn or not depends on -Wpointer-arith, and even if not, pedwarn can warn rather than error etc. Not really sure what to do here, if it is intentional that with tf_none we = are stricter and fail even on things we could just warn or pedwarn without -pedantic-errors.=