Bug 95217 - missing -Wunused-but-set-parameter for compound assignment
Summary: missing -Wunused-but-set-parameter for compound assignment
Status: RESOLVED DUPLICATE of bug 64639
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wunused
  Show dependency treegraph
 
Reported: 2020-05-19 17:17 UTC by Martin Sebor
Modified: 2021-04-22 21:59 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2020-05-19 17:17:23 UTC
GCC issues -Wunused-but-set-parameter for function arguments used only as the left operand of ordinary assignment expressions but it fails to diagnose any other equivalent forms of modifications whose result is unused, including compound assignment and increment.  It should diagnose all such expressions.

$ cat x.c && gcc -S -Wall -Wextra -Wunused-but-set-parameter x.c
void f8 (int *p)
{
  p = 0;           // -Wunused-but-set-parameter (expected)
}

void f1 (int *p)
{
  p += 1;          // missing warning
}

void f2 (int *p)
{
  p = p + 1;       // missing warning
}

void f3 (int *p)
{
  ++p;             // missing warning
}

x.c: In function ‘f8’:
x.c:1:15: warning: parameter ‘p’ set but not used [-Wunused-but-set-parameter]
    1 | void f8 (int *p)
      |          ~~~~~^
Comment 1 Martin Sebor 2020-05-19 17:19:33 UTC
This should probably be handled at the same time as pr64639, so making it a dupe.

*** This bug has been marked as a duplicate of bug 64639 ***