From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A9F5F3857C54; Mon, 13 Jul 2020 12:18:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9F5F3857C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594642731; bh=7bSgOMfJHu33LG4NqUmGfl/3mim+ypSSOrrShxTGffU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WTku4hcuVAY8+tlrUrIJ0BINPkahofI9sISYyyOy59TaSAuwo5Z2c/vF/eF02yv0e 5WAuoyvcKrdtv33aInRy17pX+0Trzdy5IW451z2OKQ40Iz/CIDmitktOVATh4prfMG b392s0n1lP7gMaUrX9u52gKyrqcuR35AbS1rmA7Q= 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:18:51 +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: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: 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: Mon, 13 Jul 2020 12:18:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96182 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- E.g. constexpr int foo (int x) { if (x =3D=3D 5) return 3; } constexpr int a =3D= foo (5); is accepted just with warning by both compilers and I think that is right, = it is only an error if one does constexpr int b =3D foo (4); or similar. But for some reason clang treats your case differently (when there are no return statements at all), but only in constexpr functions. Not sure how i= s it backed up, unless the standard says that a constexpr function must have a return statement or something similar, not sure if that is ok. It is true = that in these cases all invocations of such function in constant expression cont= exts will result in an error, but if you don't invoke them...=