public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
@ 2020-05-26 19:33 ed at catmur dot uk
  2020-05-26 22:06 ` [Bug c++/95344] " mpolacek at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ed at catmur dot uk @ 2020-05-26 19:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95344
           Summary: Wparentheses (assignment used as truth value) on
                    parenthesized ternary conditional E2
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ed at catmur dot uk
  Target Milestone: ---

void f(int i) {
    bool b = false;
    if (i == 99 ? (b = true) : false)
        ;
}

warning: suggest parentheses around assignment used as truth value
[-Wparentheses]
    3 |     if (i == 99 ? (b = true) : false)
      |                  ~~~^~~~~~~

Per Godbolt, issue exists from 9.1 through current trunk (11.0).

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/95344] Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
  2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
@ 2020-05-26 22:06 ` mpolacek at gcc dot gnu.org
  2020-05-26 23:09 ` mpolacek at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-26 22:06 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2020-05-26
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Chagned in r267272.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/95344] Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
  2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
  2020-05-26 22:06 ` [Bug c++/95344] " mpolacek at gcc dot gnu.org
@ 2020-05-26 23:09 ` mpolacek at gcc dot gnu.org
  2020-05-26 23:10 ` [Bug c++/95344] [9/10/11 Regression] " mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-26 23:09 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/95344] [9/10/11 Regression] Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
  2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
  2020-05-26 22:06 ` [Bug c++/95344] " mpolacek at gcc dot gnu.org
  2020-05-26 23:09 ` mpolacek at gcc dot gnu.org
@ 2020-05-26 23:10 ` mpolacek at gcc dot gnu.org
  2020-05-27  1:19 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-26 23:10 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.4
           Keywords|                            |diagnostic
            Summary|Wparentheses (assignment    |[9/10/11 Regression]
                   |used as truth value) on     |Wparentheses (assignment
                   |parenthesized ternary       |used as truth value) on
                   |conditional E2              |parenthesized ternary
                   |                            |conditional E2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/95344] [9/10/11 Regression] Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
  2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
                   ` (2 preceding siblings ...)
  2020-05-26 23:10 ` [Bug c++/95344] [9/10/11 Regression] " mpolacek at gcc dot gnu.org
@ 2020-05-27  1:19 ` mpolacek at gcc dot gnu.org
  2020-05-27  7:39 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-27  1:19 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546574.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/95344] [9/10/11 Regression] Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
  2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
                   ` (3 preceding siblings ...)
  2020-05-27  1:19 ` mpolacek at gcc dot gnu.org
@ 2020-05-27  7:39 ` rguenth at gcc dot gnu.org
  2020-05-29 16:32 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-27  7:39 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/95344] [9/10/11 Regression] Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
  2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
                   ` (4 preceding siblings ...)
  2020-05-27  7:39 ` rguenth at gcc dot gnu.org
@ 2020-05-29 16:32 ` cvs-commit at gcc dot gnu.org
  2020-05-29 16:32 ` [Bug c++/95344] [9/10 " mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-29 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:1f32d5294f51614f5637d81c522fccacc124f141

commit r11-729-g1f32d5294f51614f5637d81c522fccacc124f141
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue May 26 19:59:26 2020 -0400

    c++: Fix bogus -Wparentheses warning [PR95344]

    Since r267272, which added location wrappers, cp_fold loses
    TREE_NO_WARNING on a MODIFY_EXPR that finish_parenthesized_expr set, and
    that results in a bogus -Wparentheses warning.

    I.e., previously we had "b = 1" but now we have "VIEW_CONVERT_EXPR<bool>(b)
= 1"
    and cp_fold_maybe_rvalue folds away the location wrapper and so we do
    2718             x = fold_build2_loc (loc, code, TREE_TYPE (x), op0, op1);
    in cp_fold and the flag is lost.

            PR c++/95344
            * cp-gimplify.c (cp_fold) <case MODIFY_EXPR>: Don't set
            TREE_THIS_VOLATILE here.
            (cp_fold): Set it here along with TREE_NO_WARNING.

            * c-c++-common/Wparentheses-2.c: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/95344] [9/10 Regression] Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
  2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
                   ` (5 preceding siblings ...)
  2020-05-29 16:32 ` cvs-commit at gcc dot gnu.org
@ 2020-05-29 16:32 ` mpolacek at gcc dot gnu.org
  2020-06-11 20:28 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-29 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11 Regression]        |[9/10 Regression]
                   |Wparentheses (assignment    |Wparentheses (assignment
                   |used as truth value) on     |used as truth value) on
                   |parenthesized ternary       |parenthesized ternary
                   |conditional E2              |conditional E2

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk so far.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/95344] [9/10 Regression] Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
  2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
                   ` (6 preceding siblings ...)
  2020-05-29 16:32 ` [Bug c++/95344] [9/10 " mpolacek at gcc dot gnu.org
@ 2020-06-11 20:28 ` cvs-commit at gcc dot gnu.org
  2020-06-11 22:38 ` [Bug c++/95344] [9 " cvs-commit at gcc dot gnu.org
  2020-06-11 22:39 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-11 20:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:4c07da7bec0c952e4918323222c2baa85f0a29f1

commit r10-8278-g4c07da7bec0c952e4918323222c2baa85f0a29f1
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Jun 11 16:27:59 2020 -0400

    c++: Fix bogus -Wparentheses warning [PR95344]

    Since r267272, which added location wrappers, cp_fold loses
    TREE_NO_WARNING on a MODIFY_EXPR that finish_parenthesized_expr set, and
    that results in a bogus -Wparentheses warning.

    I.e., previously we had "b = 1" but now we have "VIEW_CONVERT_EXPR<bool>(b)
= 1"
    and cp_fold_maybe_rvalue folds away the location wrapper and so we do
    2718             x = fold_build2_loc (loc, code, TREE_TYPE (x), op0, op1);
    in cp_fold and the flag is lost.

            PR c++/95344
            * cp-gimplify.c (cp_fold) <case MODIFY_EXPR>: Don't set
            TREE_THIS_VOLATILE here.
            (cp_fold): Set it here along with TREE_NO_WARNING.

            * c-c++-common/Wparentheses-2.c: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/95344] [9 Regression] Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
  2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
                   ` (7 preceding siblings ...)
  2020-06-11 20:28 ` cvs-commit at gcc dot gnu.org
@ 2020-06-11 22:38 ` cvs-commit at gcc dot gnu.org
  2020-06-11 22:39 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-11 22:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 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:74eb19c2499c1b9011629799e16d74f299f35b33

commit r9-8669-g74eb19c2499c1b9011629799e16d74f299f35b33
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Jun 11 18:38:00 2020 -0400

    c++: Fix bogus -Wparentheses warning [PR95344]

    Since r267272, which added location wrappers, cp_fold loses
    TREE_NO_WARNING on a MODIFY_EXPR that finish_parenthesized_expr set, and
    that results in a bogus -Wparentheses warning.

    I.e., previously we had "b = 1" but now we have "VIEW_CONVERT_EXPR<bool>(b)
= 1"
    and cp_fold_maybe_rvalue folds away the location wrapper and so we do
    2718             x = fold_build2_loc (loc, code, TREE_TYPE (x), op0, op1);
    in cp_fold and the flag is lost.

            PR c++/95344
            * cp-gimplify.c (cp_fold) <case MODIFY_EXPR>: Don't set
            TREE_THIS_VOLATILE here.
            (cp_fold): Set it here along with TREE_NO_WARNING.

            * c-c++-common/Wparentheses-2.c: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/95344] [9 Regression] Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2
  2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
                   ` (8 preceding siblings ...)
  2020-06-11 22:38 ` [Bug c++/95344] [9 " cvs-commit at gcc dot gnu.org
@ 2020-06-11 22:39 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-11 22:39 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-06-11 22:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-26 19:33 [Bug c++/95344] New: Wparentheses (assignment used as truth value) on parenthesized ternary conditional E2 ed at catmur dot uk
2020-05-26 22:06 ` [Bug c++/95344] " mpolacek at gcc dot gnu.org
2020-05-26 23:09 ` mpolacek at gcc dot gnu.org
2020-05-26 23:10 ` [Bug c++/95344] [9/10/11 Regression] " mpolacek at gcc dot gnu.org
2020-05-27  1:19 ` mpolacek at gcc dot gnu.org
2020-05-27  7:39 ` rguenth at gcc dot gnu.org
2020-05-29 16:32 ` cvs-commit at gcc dot gnu.org
2020-05-29 16:32 ` [Bug c++/95344] [9/10 " mpolacek at gcc dot gnu.org
2020-06-11 20:28 ` cvs-commit at gcc dot gnu.org
2020-06-11 22:38 ` [Bug c++/95344] [9 " cvs-commit at gcc dot gnu.org
2020-06-11 22:39 ` mpolacek at gcc dot gnu.org

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).