public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14710] Warning about useless casts
[not found] <bug-14710-4@http.gcc.gnu.org/bugzilla/>
@ 2012-03-14 10:42 ` paolo.carlini at oracle dot com
2012-03-14 10:58 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-14 10:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |paolo.carlini at oracle dot
| |com
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-14 10:36:10 UTC ---
Jason, what do you think about this very old request? Implementing the warning
itself should be pretty trivial (and we could have outside -Wall and -Wextra,
thus should bother no one), but I'm not sure we really want it. Then I'm not
sure where we want to draw the line, eg, in the provided snippet I'm not 100%
sure about the base class case.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
[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
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-14 10:58 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
[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
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-14 12:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-14 11:47:30 UTC ---
Indeed, I was vaguely considering similar things..
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
[not found] <bug-14710-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
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
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2012-03-14 18:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> 2012-03-14 18:00:33 UTC ---
I wouldn't warn about a cast that changes the type or value category of an
expression at all, or a cast that ends up being the same type as the result of
template instantiation. But a warning for (A*)&a seems reasonable.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
[not found] <bug-14710-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
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
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-14 23:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC|paolo.carlini at oracle dot |
|com |
AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot
|gnu.org |com
Target Milestone|--- |4.8.0
--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-14 23:10:06 UTC ---
Ok, thanks. Let's see..
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
[not found] <bug-14710-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
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
7 siblings, 0 replies; 12+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-03-19 15:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
--- Comment #10 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-03-19 15:51:36 UTC ---
Author: paolo
Date: Mon Mar 19 15:51:25 2012
New Revision: 185524
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=185524
Log:
2012-03-16 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/14710
* doc/invoke.texi: Document -Wuseless-cast.
/c-family
2012-03-16 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/14710
* c.opt ([Wuseless-cast]): Add.
/cp
2012-03-16 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/14710
* cp-tree.h (maybe_warn_about_useless_cast): Declare.
* typeck.c (maybe_warn_about_useless_cast): Define.
(build_reinterpret_cast, build_const_cast,
build_static_cast, cp_build_c_cast): Use it.
* rtti.c (build_dynamic_cast): Likewise.
* pt.c (tsubst_copy_and_build, case CAST_EXPR): Increment/decrement
c_inhibit_evaluation_warnings before/after the build_* calls.
/testsuite
2012-03-16 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/14710
* g++.dg/warn/Wuseless-cast.C: New.
Added:
trunk/gcc/testsuite/g++.dg/warn/Wuseless-cast.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c.opt
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/pt.c
trunk/gcc/cp/rtti.c
trunk/gcc/cp/tree.c
trunk/gcc/cp/typeck.c
trunk/gcc/doc/invoke.texi
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
[not found] <bug-14710-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
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
7 siblings, 0 replies; 12+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-19 15:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #11 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-19 15:54:35 UTC ---
Done.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
[not found] <bug-14710-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2012-03-19 15:56 ` paolo.carlini at oracle dot com
@ 2014-02-26 21:28 ` jason at gcc dot gnu.org
7 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2014-02-26 21:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14710
--- Comment #12 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Wed Feb 26 21:28:08 2014
New Revision: 208183
URL: http://gcc.gnu.org/viewcvs?rev=208183&root=gcc&view=rev
Log:
PR c++/59231
PR c++/11586
PR c++/14710
PR c++/57132
gcc/
* c-common.c (shorten_compare): Don't check
c_inhibit_evaluation_warnings.
gcc/cp/
* pt.c (struct warning_sentinel): New.
(tsubst_copy_and_build): Use it instead of
c_inhibit_evaluation_warnings.
Added:
trunk/gcc/testsuite/g++.dg/warn/Wsign-compare-7.C
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-common.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/cp/typeck.c
trunk/gcc/testsuite/g++.dg/cilk-plus/AN/array_test2_tplt.cc
trunk/gcc/testsuite/g++.dg/cpp0x/overflow1.C
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
2004-03-24 6:35 [Bug c/14710] New: " 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; 12+ 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] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
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
3 siblings, 0 replies; 12+ 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] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
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
3 siblings, 0 replies; 12+ 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] 12+ messages in thread
* [Bug c++/14710] Warning about useless casts
2004-03-24 6:35 [Bug c/14710] New: " 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; 12+ 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] 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).