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

kmk at ssl dot org gcc-bugzilla@gcc.gnu.org
Sun Feb 27 16:33:00 GMT 2005

------- Additional Comments From kmk at ssl dot org  2005-02-27 05:40 -------
Actually, the documentation clearly claims:

"Warn WHENEVER a pointer is cast so as to remove a type qualifier from the
target type."

It does not say:

"Warn whenever a pointer is cast to ANOTHER POINTER in such a way that it
removes a type qualifier from the target type."

Casting a const pointer to any non-pointer object will remove the const
qualifier from the pointer, no matter how you look at it. To not flag this abuse
is not only in obvious contradiction with the documentation, it makes the option
utterly useless for detecting intentionally dangerous behavior by programmers.

           What    |Removed                     |Added
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


More information about the Gcc-bugs mailing list