[LLVMbugs] [Bug 18711] New: -Wcast-align doesn't special case char*

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 3 10:23:37 PST 2014


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

            Bug ID: 18711
           Summary: -Wcast-align doesn't special case char*
           Product: clang
           Version: 3.4
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: htam at apple.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ cat foo.c
void foo(char* bar) {
    *(int*)(bar + 4) = 7;
}

$ clang foo.c -c -o /dev/null -Wcast-align
foo.c:2:6: warning: cast from 'char *' to 'int *' increases required alignment
     from 1 to 4 [-Wcast-align]
   *(int*)(bar + 4) = 7;
    ^~~~~~~~~~~~~~~
1 warning generated.

The -Wcast-align warning should not be generated by casts from char*, since it
is magical and often points to things that are not remotely related to char.

-- 
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/20140203/b9adf892/attachment.html>


More information about the llvm-bugs mailing list