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

            Bug ID: 95217
           Summary: missing -Wunused-but-set-parameter for compound
                    assignment
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

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)
      |          ~~~~~^

Reply via email to