From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AAA373857348; Tue, 19 Dec 2023 21:19:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AAA373857348 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703020766; bh=UCVwEWrBr4nwGZsFqlRjVzrwXkkLp0B1Wo+qIG+/cLw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Vcn1Q8FNCvVL630rIObOoMmxeMkSluiFcGe1F4HNzd+hnfBvN00dRp1n+Kbh0Hnr7 3vU7oBunBW7Kr4GGfhYIIVmWIBeoFLk7einqGVcRN6zfTrT598H2CTSIW+rtYkhWZV t3jx71G8whvNTcTYFojeI6G3SeB96pjAwRdHIohY= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102420] null pointer dereference during constant evaluation not rejected Date: Tue, 19 Dec 2023 21:19:26 +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: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102420 --- Comment #3 from GCC Commits --- The master branch has been updated by Nathaniel Shead : https://gcc.gnu.org/g:5ba949c096f5250aa4efb94fb7c94d1304c1bf39 commit r14-6722-g5ba949c096f5250aa4efb94fb7c94d1304c1bf39 Author: Nathaniel Shead Date: Sun Dec 17 12:46:02 2023 +1100 c++: Check null pointer deref when calling memfn in constexpr [PR102420] Calling a non-static member function on a null pointer is undefined behaviour (see [expr.ref] p8) and should error in constant evaluation, even if the 'this' pointer is never actually accessed within that function. One catch is that currently, the function pointer conversion operator for lambdas passes a null pointer as the 'this' pointer to the underlying 'operator()', so for now we ignore such calls. PR c++/102420 gcc/cp/ChangeLog: * constexpr.cc (cxx_bind_parameters_in_call): Check for calling non-static member functions with a null pointer. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-memfn2.C: New test. Signed-off-by: Nathaniel Shead =