From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23168 invoked by alias); 28 Aug 2015 10:06:22 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 23093 invoked by uid 48); 28 Aug 2015 10:06:17 -0000 From: "Casey at Carter dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/67371] Never executed "throw" in constexpr function fails to compile Date: Fri, 28 Aug 2015 10:06:00 -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: 6.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: Casey at Carter dot net 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: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-08/txt/msg01934.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67371 --- Comment #7 from Casey Carter --- (In reply to Markus Trippelsdorf from comment #6) > Well, my patch survives regression testing and fixes the issue. > > But unfortunately it leads to accept invalid cases like: > > constexpr int f1() { > throw; > return 0; > } > > or > > constexpr void f2() { > throw; > } > > (Even clang accepts f2.) I think it would be better for the compiler to accept constexpr functions that are ill-formed NDR - like f1 and f2 - than to reject constexpr functions that are conforming like: constexpr int f3() { return 0; throw; } constexpr int* f4(bool b) { if (b) { return nullptr; } else { return new int{42}; } }