[llvm-bugs] [Bug 33580] New: Inconsistent Wunused-value warning with respect to macros

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 24 10:39:46 PDT 2017


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

            Bug ID: 33580
           Summary: Inconsistent Wunused-value warning with respect to
                    macros
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: fuse001project at gmail.com
                CC: llvm-bugs at lists.llvm.org

Clang seems to ignore unused variables that are introduced by macro expansion.

$ cat -n test.c

     1  #include <stdio.h>
     2
     3  int v[2];
     4
     5  #define M 2, 3
     6
     7  int main(void) {
     8
     9    v[0] = M;
    10    printf("%d\n", v[0]);
    11    v[0] =  5, 6;
    12    printf("%d\n", v[0]);
    13    return 0;
    14
    15  }

When compiling with `clang -Wunused-value test.c`, it reports

test.c:11:14: warning: expression result unused [-Wunused-value]
  v[0] =  5, 6;
             ^
1 warning generated.

But in fact line 9 also contains an unused variable when M is expanded.


The tested clangs include: clang-3.8(tags/RELEASE_380/final) and
clang-4.0(tags/RELEASE_400/rc1) on Ubuntu; clang-4.0.0 (tags/RELEASE_400/final)
and Apple LLVM version 8.1.0 (clang-802.0.42) on MacOS.

gcc reports 2 unused variables when `-Wunused-value` is turned on (default
off).

-- 
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/20170624/3075601b/attachment.html>


More information about the llvm-bugs mailing list