[llvm-bugs] [Bug 52274] New: -Wunused-but-set-parameter diagnostic warns about parameter += 1 but not parameter++

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 23 10:31:09 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52274

            Bug ID: 52274
           Summary: -Wunused-but-set-parameter diagnostic warns about
                    parameter += 1 but not parameter++
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: cpeterson at mozilla.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

When compiled with `clang++ -Wunused-but-set-parameter test.cpp`, the following
test program reports the following warnings:

test.cpp:8:14: warning: parameter 'a' set but not used
[-Wunused-but-set-parameter]
void foo(int a, int b, int c) {
             ^
test.cpp:8:21: warning: parameter 'b' set but not used
[-Wunused-but-set-parameter]
void foo(int a, int b, int c) {


void foo(int a, int b, int c) {
  a = 1;  // PASS: expect warning, got warning
  b += 1; // PASS: expect warning, got warning
  c++;    // FAIL? expect warning because c++ result unused, got no warning
}

If `b += 1` is considered "setting but not using" b, then shouldn't `c++` also
be considered "setting but not using" parameter c?

I am using Homebrew clang version 13.0.0 on macOS 11.6.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211023/c505f3e5/attachment.html>


More information about the llvm-bugs mailing list