[llvm-bugs] [Bug 25120] New: Warn on pointless casts with fixit to remove them
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 9 05:50:04 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=25120
Bug ID: 25120
Summary: Warn on pointless casts with fixit to remove them
Product: clang
Version: 3.5
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: bugzilla at tecnocode.co.uk
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
It would be nice if Clang warned about pointless casts:
• casting a value of type (X*) to (X*)
• casting a value of type (X*) to a qualified version of (X*), like (const X*)
because these casts are entirely pointless as per §6.5.4¶5 of
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf, plus footnote 104.
test.c:
void some_func (const char *const_param) {}
int
main (void)
{
char *str = "hi";
some_func (str); /* fine */
some_func ((const char *) str); /* should warn */
some_func ((char *) str); /* should warn */
}
$ clang -Weverything -Wno-missing-prototypes -Wno-unused-parameter test.c
$ clang --version
clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-redhat-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/20151009/7aa10864/attachment-0001.html>
More information about the llvm-bugs
mailing list