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

joseph at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Sun Feb 27 20:45:00 GMT 2005


------- Additional Comments From joseph at codesourcery dot com  2005-02-27 14:59 -------
Subject: Re:  -Wcast-qual option is easily evaded

On Sun, 27 Feb 2005, schwab at suse dot de wrote:

> Casting to an integer does not remove the qualifier from the target type, it 
> removes the target type completely.  Since an integer is not a pointer, there 
> cannot be a target type any more.  So the documentation is correct. 

I would add that it is *useful* for programmers to be able to avoid the 
warning in cases where they know what they are doing.  That is, it's a 
*feature* that one can define

#define remove_const(x, type) ((type)(size_t)(x))

and so avoid the warnings.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20229



More information about the Gcc-bugs mailing list