-Wold-style-cast for g++, please ?

Alexandre Oliva oliva@dcc.unicamp.br
Thu Sep 25 12:58:00 GMT 1997


Christian Millour writes:

> I know there are legitimate uses for old-style casts (e.g. downcasting
> from a private base) so it should be standalone (i.e. not make it to
> -W, -Wall or -pedantic).

Here's a patch that creates -Wold-style-cast, produced whenever an
old-style cast is issued.  I added it to -Wall too; it should be easy
to change this.

This is just a basic implementation; maybe it should be improved in
order to check whether the cast would be valid as any other kind of
cast, and suggest it instead.  I was thinking of factoring out the
test parts of build_{static,reinterpret,const}_cast so that I could
use them before issuing the warning.  However, since old-style-casts
can accomplish the same as two new-style casts at once, I don't think
I'm able to do it (yet) :-(

Regards,

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
Universidade Estadual de Campinas, SP, Brasil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: oldcast.diff
Type: text/x-diff
Size: 1675 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/19970925/103f719f/attachment.bin>


More information about the Gcc mailing list