[Bug c/97748] Preincrement of _Complex gives bogus warning = "value computed is not used"

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Nov 7 08:30:10 GMT 2020


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Adjusted testcase:
/* PR c/97748 */
/* { dg-do compile } */
/* { dg-options "-Wunused-value" } */

double _Complex
foo (double _Complex x)
{
  ++x;  /* { dg-bogus "value computed is not used" } */
  return x;
}

double _Complex
bar (double _Complex x)
{
  --x;  /* { dg-bogus "value computed is not used" } */
  return x;
}

The tree that is not used is a COMPLEX_EXPR:
(void) COMPLEX_EXPR < ++REALPART_EXPR <x>, IMAGPART_EXPR <x>>
which would be used only if the result of the post increment or decrement would
be actually used.
So, either we should mark the COMPLEX_EXPR created for the pre-increments
TREE_NO_WARNING, or the -Wunused-value would need to look through the
COMPLEX_EXPR.


More information about the Gcc-bugs mailing list