[Bug c++/87327] [8 Regression] Calling member functions on captured constexpr variables "is not a constant expression"

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Feb 26 04:24:00 GMT 2020


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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:6470e8caa2bd331fb6e21524d6c14662531cfa9b

commit r8-10072-g6470e8caa2bd331fb6e21524d6c14662531cfa9b
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Feb 25 21:29:03 2020 -0500

    PR c++/86429 - constexpr variable in lambda.

    When we refer to a captured variable from a constant-expression context
    inside a lambda, the closure (like any function parameter) is not constant
    because we aren't in a call, so we don't have an argument.  So the capture
    is non-constant.  But if the captured variable is constant, we might be
able
    to use it directly in constexpr evaluation.

    gcc/cp/ChangeLog
    2020-02-25  Jason Merrill  <jason@redhat.com>

        PR c++/86429 - constexpr variable in lambda.
        PR c++/82643
        PR c++/87327
        * constexpr.c (cxx_eval_constant_expression): In a lambda function,
        try evaluating the captured variable directly.


More information about the Gcc-bugs mailing list