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; 5+ 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] 5+ messages in thread
* [Bug c++/14710] Warning about useless casts
2004-03-24 6:35 [Bug c/14710] New: Warning about useless casts debian-gcc at lists dot debian dot org
@ 2004-03-24 6:40 ` pinskia at gcc dot gnu dot org
2004-03-24 16:50 ` gdr at integrable-solutions dot net
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-24 6:40 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-24 06:40 -------
Confirmed, but I do not know how useful this is.
--
What |Removed |Added
----------------------------------------------------------------------------
Component|c |c++
Keywords| |diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/14710] Warning about useless casts
2004-03-24 6:35 [Bug c/14710] New: Warning about useless casts 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
3 siblings, 0 replies; 5+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-03-24 16:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2004-03-24 16:50 -------
Subject: Re: Warning about useless casts
"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| Confirmed, but I do not know how useful this is.
Please can you make it an enhancement with low priority?
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/14710] Warning about useless casts
2004-03-24 6:35 [Bug c/14710] New: Warning about useless casts 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
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-24 16:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-24 16:56 -------
Should have confirmed it.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Priority|P2 |P3
Last reconfirmed|0000-00-00 00:00:00 |2004-03-24 16:56:18
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/14710] Warning about useless casts
2004-03-24 6:35 [Bug c/14710] New: Warning about useless casts debian-gcc at lists dot debian dot org
` (2 preceding siblings ...)
2004-03-24 16:56 ` pinskia at gcc dot gnu dot org
@ 2004-04-02 7:49 ` stl at caltech dot edu
3 siblings, 0 replies; 5+ messages in thread
From: stl at caltech dot edu @ 2004-04-02 7:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From stl at caltech dot edu 2004-04-02 07:49 -------
I am in favor of this warning, though I don't expect that it would occur often
(except in C, where programmers incessantly cast the return values of malloc()
and friends).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-04-02 7:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-24 6:35 [Bug c/14710] New: Warning about useless casts 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).