[PATCHv2] implement -Wold-style-cast

Jonathan Sauer jonathan.sauer at gmx.de
Fri Nov 22 10:05:11 PST 2013


Hello,

> It would be great if it suggested a fixit to change the cast to the
> correct C++ cast or a combination of those (for example, static cast
> of a const cast).  Is it always possible to do this in a template?

ยง5.4p4 specifies which conversions a C-style cast (called "explicit type
conversion" in the standard) can perform:

| - a const_cast
| - a static_cast
| - a static_cast followed by a const_cast
| - a reinterpret_cast
| - a reinterpret_cast followed by a const_cast

It also states:

| If a conversion can be interpreted in more than one of the ways listed above,
| the interpretation that appears first in the list is used

As the list of possible conversions depends on the concrete type, I don't
think it is possible to provide a fix-it when dealing with dependent types
of a template (non-dependent types should be fine though).


Jonathan



More information about the cfe-commits mailing list