From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AC7863885C2A; Mon, 13 Jul 2020 12:36:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC7863885C2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594643773; bh=24VV6rqD3uZcR1miSvyUEA7soScWTM3Ic8BVbv/mIF0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=amgVkYvA/DNZ6ijJWAtUQpqmZutf6ZuOk6pS74ktNDxZkJaPt7mujXxCmw3imxtAD Tp/7X6odiD4Cz43AtCw6OkOOM+BWVux+GeRt7YE6mVHBkCBV74tSG7xfIERA/AmoWi leq43zVuLvmvxy9k+vH5zIkp2GzVKnJdFmQ44b1s= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96182] GCC accepts constexpr function with no return-statement Date: Mon, 13 Jul 2020 12:36:13 +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: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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: Mon, 13 Jul 2020 12:36:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96182 --- Comment #6 from Jakub Jelinek --- So we could do something like: --- gcc/cp/decl.c.jj 2020-07-09 11:27:51.088908783 +0200 +++ gcc/cp/decl.c 2020-07-13 14:34:59.887259561 +0200 @@ -17164,7 +17164,9 @@ finish_function (bool inline_p) BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) =3D fndecl; /* Complain if there's just no return statement. */ - if (warn_return_type + if ((warn_return_type + || (cxx_dialect >=3D cxx14 + && DECL_DECLARED_CONSTEXPR_P (fndecl))) && !VOID_TYPE_P (TREE_TYPE (fntype)) && !dependent_type_p (TREE_TYPE (fntype)) && !current_function_returns_value && !current_function_returns_null @@ -17196,8 +17198,12 @@ finish_function (bool inline_p) global_dc->option_state)) add_return_star_this_fixit (&richloc, fndecl); } - if (warning_at (&richloc, OPT_Wreturn_type, - "no return statement in function returning non-void")) + if (cxx_dialect >=3D cxx14 && DECL_DECLARED_CONSTEXPR_P (fndecl)) + error_at (&richloc, "no return statement in % function " + "returning non-void"); + else if (warning_at (&richloc, OPT_Wreturn_type, + "no return statement in function returning " + "non-void")) TREE_NO_WARNING (fndecl) =3D 1; } and look for what breaks.=