[llvm-bugs] [Bug 27313] New: Wrong warning -Wunevaluated-expression for sizeof of VLA

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 10 13:57:38 PDT 2016


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

            Bug ID: 27313
           Summary: Wrong warning -Wunevaluated-expression for sizeof of
                    VLA
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: cherepan at mccme.ru
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Compiling the program:

int main()
{
  int a[1][(0, 1)];
  int i = 0;
  sizeof a[i++];
}

gives such warnings:

$ clang -Wall example.c 
example.c:5:10: warning: expression with side effects has no effect in an
unevaluated context [-Wunevaluated-expression]
  sizeof a[i++];
         ^
example.c:5:3: warning: expression result unused [-Wunused-value]
  sizeof a[i++];
  ^~~~~~~~~~~~~
2 warnings generated.

The first warning is wrong: `a` is VLA and a[i++] in sizeof is evaluated. The
program is compiled just fine, only the warning is wrong.

-- 
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/20160410/3a358e61/attachment-0001.html>


More information about the llvm-bugs mailing list