[llvm-bugs] [Bug 51849] New: False positives for -Wunused-but-set-variable with op assignment operators (e.g. `|=`)

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 14 08:10:56 PDT 2021


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

            Bug ID: 51849
           Summary: False positives for -Wunused-but-set-variable with op
                    assignment operators (e.g. `|=`)
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: luismarques at lowrisc.org
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

I think this is a false positive.
This happens with trunk (9aeecdfa8e91) and the latest RC (13.0.0-rc3):

$ cat test.c
void f(void) {
  int result = 0;
#ifdef BUG
    result |= 42;
#else
    result = result | 42;
#endif
}
$ ./bin/clang -Wunused-but-set-variable -c test.c
$ ./bin/clang -Wunused-but-set-variable -c test.c -DBUG
test.c:2:7: warning: variable 'result' set but not used
[-Wunused-but-set-variable]
  int result = 0;
      ^
1 warning generated.

-- 
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/20210914/2c3c3429/attachment.html>


More information about the llvm-bugs mailing list