From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 40FDD3858C33; Mon, 16 Oct 2023 12:33:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40FDD3858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697459611; bh=AGNtSTqfHuLCJtdc/QiRLkRyAK83TpNtfnUMA9skiuc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ObDJ4IsD/Sd70lTuFJ/CayaleDjHVYM9onVpzMYuw2MTQTRlrdJSnVcM8pUaRXFTR CYT4ayCgB1IGdsznQEndfiFZVhTLh4DMMFokqHokf+ISjyWX41awIqH7CqhabtX9N9 dunkgrkMctosgFT4B5d9/0DB2EdOR7QCB0iR+FUk= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111272] [13/14 Regression] Truncated error messages with -std=c++23 and -std=c++26 Date: Mon, 16 Oct 2023 12:33:30 +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: 14.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111272 --- Comment #6 from CVS Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:a22eeaca5ce753a0a3c22013ee3ecde04c71c2f4 commit r14-4659-ga22eeaca5ce753a0a3c22013ee3ecde04c71c2f4 Author: Marek Polacek Date: Fri Oct 13 16:47:47 2023 -0400 c++: fix truncated diagnostic in C++23 [PR111272] In C++23, since P2448, a constexpr function F that calls a non-constexpr function N is OK as long as we don't actually call F in a constexpr context. So instead of giving an error in maybe_save_constexpr_fundef, we only give an error when evaluating the call. Unfortunately, as shown in this PR, the diagnostic can be truncated: z.C:10:13: note: 'constexpr Jam::Jam()' is not usable as a 'constexpr' function because: 10 | constexpr Jam() { ft(); } | ^~~ ...because what? With this patch, we say: z.C:10:13: note: 'constexpr Jam::Jam()' is not usable as a 'constexpr' function because: 10 | constexpr Jam() { ft(); } | ^~~ z.C:10:23: error: call to non-'constexpr' function 'int Jam::ft()' 10 | constexpr Jam() { ft(); } | ~~^~ z.C:8:7: note: 'int Jam::ft()' declared here 8 | int ft() { return 42; } | ^~ Like maybe_save_constexpr_fundef, explain_invalid_constexpr_fn should also check the body of a constructor, not just the mem-initializer. PR c++/111272 gcc/cp/ChangeLog: * constexpr.cc (explain_invalid_constexpr_fn): Also check the b= ody of a constructor in C++14 and up. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/constexpr-diag1.C: New test.=