public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-102420-4-XLkoRrREBm@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102420-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102420

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:

https://gcc.gnu.org/g:5ba949c096f5250aa4efb94fb7c94d1304c1bf39

commit r14-6722-g5ba949c096f5250aa4efb94fb7c94d1304c1bf39
Author: Nathaniel Shead <nathanieloshead@gmail.com>
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 <nathanieloshead@gmail.com>

      parent reply	other threads:[~2023-12-19 21:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20 22:13 [Bug c++/102420] New: null pointer dereference constant johelegp at gmail dot com
2021-09-20 22:14 ` [Bug c++/102420] null pointer dereference during constant evaluation not rejected johelegp at gmail dot com
2021-09-20 22:25 ` pinskia at gcc dot gnu.org
2023-12-19 21:19 ` cvs-commit at gcc dot gnu.org [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102420-4-XLkoRrREBm@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).