This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/20229] -Wcast-qual option is easily evaded
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Feb 2005 05:02:59 -0000
- Subject: [Bug c/20229] -Wcast-qual option is easily evaded
- References: <20050227044915.20229.kmk@ssl.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-02-27 05:02 -------
Nope the following cannot be warned about because you first change the pointer to an integer and then
cast it to a char pointer which is only defined iff int is the same size as the pointer (which is warned
about on 64bit targets):
// This, however, does not warn...but should:
evil_string_modifier((char *)(int)"Test string three.");
Not warning is correct as there is a cast inbetween.
the docs are clear:
Warn whenever a pointer is cast so as to remove a type qualifier from the target type. For example,
warn if a const char * is cast to an ordinary char *.
Since the cast to int is inbetween there, the warning does not makes sense any more.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Component|debug |c
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20229