public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/14710] New: Warning about useless casts
@ 2004-03-24  6:35 debian-gcc at lists dot debian dot org
  2004-03-24  6:40 ` [Bug c++/14710] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2004-03-24  6:35 UTC (permalink / raw)
  To: gcc-bugs

[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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-02-26 21:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-14710-4@http.gcc.gnu.org/bugzilla/>
2012-03-14 10:42 ` [Bug c++/14710] Warning about useless casts paolo.carlini at oracle dot com
2012-03-14 10:58 ` redi at gcc dot gnu.org
2012-03-14 12:54 ` paolo.carlini at oracle dot com
2012-03-14 18:33 ` jason at gcc dot gnu.org
2012-03-14 23:34 ` paolo.carlini at oracle dot com
2012-03-19 15:55 ` paolo at gcc dot gnu.org
2012-03-19 15:56 ` paolo.carlini at oracle dot com
2014-02-26 21:28 ` jason at gcc dot gnu.org
2004-03-24  6:35 [Bug c/14710] New: " debian-gcc at lists dot debian dot org
2004-03-24  6:40 ` [Bug c++/14710] " pinskia at gcc dot gnu dot org
2004-03-24 16:50 ` gdr at integrable-solutions dot net
2004-03-24 16:56 ` pinskia at gcc dot gnu dot org
2004-04-02  7:49 ` stl at caltech dot edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).