This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14710] Warning about useless casts
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 14 Mar 2012 10:52:18 +0000
- Subject: [Bug c++/14710] Warning about useless casts
- Auto-submitted: auto-generated
- References: <bug-14710-4@http.gcc.gnu.org/bugzilla/>
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.