[Bug c++/94505] Logical operator inside fold-expression: strange warning

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Apr 20 19:45:03 GMT 2020


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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:83eeda5f004c3b9cbeccd3da1c3fe58b3015e55f

commit r9-8518-g83eeda5f004c3b9cbeccd3da1c3fe58b3015e55f
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon Apr 20 15:43:49 2020 -0400

    c++: Fix bogus -Wparentheses warning with fold-expression [PR94505]

    We issue bogus -Wparentheses warnings (3 of them!) for this fold
expression:

      ((B && true) || ...)

    Firstly, issuing a warning for a compiler-generated expression is wrong
    and secondly, B && true must be wrapped in ( ) otherwise you'll get
    error: binary expression in operand of fold-expression.

            PR c++/94505 - bogus -Wparentheses warning with fold-expression.
            * pt.c (fold_expression): Add warning_sentinel for -Wparentheses
            before calling build_x_binary_op.

            * g++.dg/cpp1z/fold11.C: New test.


More information about the Gcc-bugs mailing list