[llvm-bugs] [Bug 33397] New: clang: C++: -Wcast-align is ignored for reinterpret_cast<>() casts

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 10 07:31:47 PDT 2017


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

            Bug ID: 33397
           Summary: clang: C++: -Wcast-align is ignored for
                    reinterpret_cast<>() casts
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org

int main() {
  char foo[] = "foobar";
  int bar = *(int*)(foo + 1);
  int baz = *(reinterpret_cast<int*>(foo + 1));
}

$ clang -x c++ -Wcast-align /tmp/tst.c 
/tmp/tst.c:3:14: warning: cast from 'char *' to 'int *' increases required
alignment from 1 to 4 [-Wcast-align]
  int bar = *(int*)(foo + 1);
             ^~~~~~~~~~~~~~~
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/20170610/51e1b6ef/attachment.html>


More information about the llvm-bugs mailing list