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 <nsh...@gcc.gnu.org>:

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

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

Reply via email to