https://bugs.llvm.org/show_bug.cgi?id=33929
Bug ID: 33929
Summary: -Wcast-qual should not warn about dropping 'const'
when casting to ObjC types
Product: clang
Version: trunk
Hardware: All
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangb...@nondot.org
Reporter: jordan_r...@apple.com
CC: llvm-bugs@lists.llvm.org
// clang -fsyntax-only -x objective-c -Weverything -
id reinterpretAsObject(const void *ptr) {
return (id)ptr;
}
<stdin>:2:14: warning: cast from 'const void *' to 'id' drops const qualifier
[-Wcast-qual]
return (id)ptr;
^
...however, there's no way to avoid this warning; you can't const-qualify
Objective-C object types inside the pointer. It might have been better if this
weren't a common idiom on Apple platforms, but it is---both 'const void *' and
opaque pointers to const struct types are sometimes valid Objective-C objects,
and casts to 'id', 'Class', or concrete object pointer types like 'NSString *'
are considered common and acceptable.
(If we /were/ to start warning on these all the time, they should be silenced
by adding '__bridge', and the warning should have a fix-it. But even that's
probably too much churn for Apple platforms.)
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs