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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:ff465bd8a0f0f96a00d3067018442917b194b7af

commit r12-7831-gff465bd8a0f0f96a00d3067018442917b194b7af
Author: Patrick Palka <ppa...@redhat.com>
Date:   Sat Mar 26 10:20:18 2022 -0400

    c++: diagnosing if-stmt with non-constant branches [PR105050]

    When an if-stmt is determined to be non-constant because both of its
    branches are non-constant, we issue a somewhat generic error which,
    since the error also points to the 'if' token, misleadingly suggests
    the condition is at fault:

      constexpr-105050.C:8:3: error: expression â<statement>â is not a
constant expression
          8 |   if (p != q && *p < 0)
            |   ^~

    This patch clarifies the error message to instead read:

      constexpr-105050.C:8:3: error: neither branch of âifâ is a constant
expression
          8 |   if (p != q && *p < 0)
            |   ^~

            PR c++/105050

    gcc/cp/ChangeLog:

            * constexpr.cc (potential_constant_expression_1) <case IF_STMT>:
            Clarify error message when a if-stmt is non-constant because its
            branches are non-constant.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/constexpr-105050.C: New test.

Reply via email to