[llvm-bugs] [Bug 50379] New: False positive warning on out param

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 17 15:43:30 PDT 2021


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

            Bug ID: 50379
           Summary: False positive warning on out param
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: alonzakai at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

$ cat a.cpp
void foo(int& x) {
  x = 10;
}

int main() {
  int x;
  foo(x);
  return x;
}

$ clang++ a.cpp -W
a.cpp:1:15: warning: parameter 'x' set but not used
[-Wunused-but-set-parameter]
void foo(int& x) {
              ^
1 warning generated.


It is technically true that x is set but not used, but it is an out param, so
that is a natural way to use it, and I don't think it should warn?

This changed in the last few days, based on it starting to break on our CI
today.

-- 
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/20210517/5068685a/attachment.html>


More information about the llvm-bugs mailing list