[LLVMbugs] [Bug 18147] New: -Wold-style-cast should be suppressed in the expansion of system header macros

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Dec 5 10:55:39 PST 2013


            Bug ID: 18147
           Summary: -Wold-style-cast should be suppressed in the expansion
                    of system header macros
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jonathan.sauer at gmx.de
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code (which includes itself as a system header) produces a
warning when compiled with clang r196506 and -Wold-style-cast:

#pragma clang system_header

#define FOO(a) ((int*) (a))

#include __FILE__

int main()
    int* i = FOO(0);

This results in:

% ~/LLVM/build/Release+Asserts/bin/clang++ -c -Wold-style-cast clang.cpp  
clang.cpp:12:14: warning: use of old-style cast [-Wold-style-cast]
    int* i = FOO(0);
clang.cpp:4:24: note: expanded from macro 'FOO'
#define FOO(a) ((int*) (a))
                ~~~~~~ ^
1 warning generated.

While -Wold-style-cast already is suppressed inside function definitions in
system headers, it should also be suppressed when a macro defined in a system
header is expanded outside of a system header.

(real-life examples are found in the SSE headers shipped with clang such as

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/20131205/9315cc8e/attachment.html>

More information about the llvm-bugs mailing list