[LLVMbugs] [Bug 18803] New: No -Wsequence-point warning for undefined behavior in "a[*p] = (*p += 1)"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 11 01:10:12 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18803

            Bug ID: 18803
           Summary: No -Wsequence-point warning for undefined behavior in
                    "a[*p] = (*p += 1)"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I suppose there should be an undefined behavior on *p. Gcc warns this behavior. 

$: cat s.c
void fn(int* p) {
  int a[2] = {1, 2};
  a[*p] = (*p += 1);
}
$: clang-trunk -Wsequence-point -c s.c
$: gcc-trunk -Wsequence-point -c s.c
s.c: In function ‘fn’:
s.c:3:15: warning: operation on ‘*p’ may be undefined [-Wsequence-point]
   a[*p] = (*p += 1);
               ^
$: clang-trunk --version
clang version 3.5 (trunk 201116)
Target: x86_64-unknown-linux-gnu
Thread model: posix

-- 
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/20140211/3b67c600/attachment.html>


More information about the llvm-bugs mailing list