This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/20229] -Wcast-qual option is easily evaded


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]