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++/14710] Warning about useless casts


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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-14 10:52:18 UTC ---
I can see some value in the base class case too, but whether it's useless
depends on context, here the exact same casts are not redundant because they
select between two overloads:

struct A { int a; };
struct B : A { int b; };
void func(A *);
void func(B *);

int main()
{
    B b;

    func((A*)&b);
    func(static_cast<A*>(&b));
}


Should it apply in templates? When casting to reference types as well as
pointers? That might give a warning for std::forward and similar cases, which
are entirely correct.


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