LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 4802 - -Wcast-qual not implemented
Summary: -Wcast-qual not implemented
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords: quality-of-implementation
Depends on:
Blocks:
 
Reported: 2009-08-27 11:37 PDT by Timo Sirainen
Modified: 2017-07-03 11:14 PDT (History)
9 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timo Sirainen 2009-08-27 11:37:55 PDT
int main(void)
{
	const char *x = 0;
	char *y = (char *)x;
	return 0;
}

gcc -Wcast-qual warns:

test.c:4: warning: cast discards qualifiers from pointer target type

clang warns nothing.
Comment 1 Igor Minin 2012-06-20 07:54:56 PDT
Hi! Following patch adds support for this warning  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120618/059295.html 
Please, review.
Comment 2 Bill Wendling 2013-10-16 23:00:22 PDT
Ping?
Comment 3 Roman Divacky 2014-11-21 15:18:01 PST
This was (re)implemented in r222568.
Comment 4 Roman Lebedev 2017-05-11 06:37:25 PDT
(In reply to Timo Sirainen from comment #0)
> int main(void)
> {
> 	const char *x = 0;
> 	char *y = (char *)x;
> 	return 0;
> }
> 
> gcc -Wcast-qual warns:
> 
> test.c:4: warning: cast discards qualifiers from pointer target type
> 
> clang warns nothing.

clang-4.0 still does not warn on that.
https://godbolt.org/g/3SEdPm
Comment 5 Roman Lebedev 2017-05-11 07:32:18 PDT
Upon further research, it seems that clang's -Wcast-qual does work for C, but unlike gcc's -Wcast-qual, does not do anything in C++.
Comment 6 Roman Lebedev 2017-05-11 08:47:12 PDT
Opened https://reviews.llvm.org/D33102
Do not know who to add as reviewers there.
Comment 7 Roman Lebedev 2017-07-03 11:14:38 PDT
D33102 has just re-landed.