This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/14710] New: Warning about useless casts
- From: "debian-gcc at lists dot debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Mar 2004 06:35:43 -0000
- Subject: [Bug c/14710] New: Warning about useless casts
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
[forwarded from http://bugs.debian.org/237207]
It would be nice if there was an option to add a warning about
"useless" casts. Although they are not really incorrect, they
might become incorrect/inefficient as the program evolves. Ie;
struct A { int a; };
struct B : A { int b; };
void func(A *a) { ++a; }
int main(int ac, char **av)
{
A a;
B b;
func((A*)&a); // Useless cast since a already is an A.
func(static_cast<A*>(&a)); // Just as useless.
func((A*)&b); // Useless cast since b is a kind of A.
func(static_cast<A*>(&b)); // Just as useless.
return 0;
}
--
Summary: Warning about useless casts
Product: gcc
Version: 3.3.4
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: debian-gcc at lists dot debian dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710