public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead [not found] <bug-85043-4@http.gcc.gnu.org/bugzilla/> @ 2022-10-18 13:15 ` mpolacek at gcc dot gnu.org 2022-10-18 13:15 ` mpolacek at gcc dot gnu.org ` (6 subsequent siblings) 7 siblings, 0 replies; 8+ messages in thread From: mpolacek at gcc dot gnu.org @ 2022-10-18 13:15 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85043 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org CC| |mpolacek at gcc dot gnu.org ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead [not found] <bug-85043-4@http.gcc.gnu.org/bugzilla/> 2022-10-18 13:15 ` [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead mpolacek at gcc dot gnu.org @ 2022-10-18 13:15 ` mpolacek at gcc dot gnu.org 2022-10-18 13:48 ` mpolacek at gcc dot gnu.org ` (5 subsequent siblings) 7 siblings, 0 replies; 8+ messages in thread From: mpolacek at gcc dot gnu.org @ 2022-10-18 13:15 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85043 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |prokofjev.d at gmail dot com --- Comment #13 from Marek Polacek <mpolacek at gcc dot gnu.org> --- *** Bug 90201 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead [not found] <bug-85043-4@http.gcc.gnu.org/bugzilla/> 2022-10-18 13:15 ` [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead mpolacek at gcc dot gnu.org 2022-10-18 13:15 ` mpolacek at gcc dot gnu.org @ 2022-10-18 13:48 ` mpolacek at gcc dot gnu.org 2022-10-19 19:30 ` cvs-commit at gcc dot gnu.org ` (4 subsequent siblings) 7 siblings, 0 replies; 8+ messages in thread From: mpolacek at gcc dot gnu.org @ 2022-10-18 13:48 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85043 --- Comment #14 from Marek Polacek <mpolacek at gcc dot gnu.org> --- I've encountered this bug with: struct S { }; void g(S&&); void f (S&& arg) { g(S(arg)); // warning: useless cast to type 'struct S' } which doesn't compile without the cast, because then "arg" is an lvalue that cannot bind to S&&. I'd like to disable then warning when a class is cast to a non-reference type. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead [not found] <bug-85043-4@http.gcc.gnu.org/bugzilla/> ` (2 preceding siblings ...) 2022-10-18 13:48 ` mpolacek at gcc dot gnu.org @ 2022-10-19 19:30 ` cvs-commit at gcc dot gnu.org 2022-10-19 19:32 ` mpolacek at gcc dot gnu.org ` (3 subsequent siblings) 7 siblings, 0 replies; 8+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2022-10-19 19:30 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85043 --- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:b3c98d6a59a6dcd5b0b52bd5676b586ef4fe785f commit r13-3388-gb3c98d6a59a6dcd5b0b52bd5676b586ef4fe785f Author: Marek Polacek <polacek@redhat.com> Date: Tue Oct 18 12:20:14 2022 -0400 c++: Mitigate -Wuseless-cast with classes [PR85043] -Wuseless-cast (not part of -Wall/-Wextra) warns here: struct S { }; void g (S&&); void f (S&& arg) { g (S(arg)); // warning: useless cast to type 'struct S' } which is wrong: the code will not compile without the cast because "arg" is an lvalue which cannot bind to S&&. This patch disables the warning when an object that isn't a prvalue is cast to a non-reference type. Therefore we still warn about the useless cast in "X(X{})". PR c++/85043 gcc/cp/ChangeLog: * typeck.cc (maybe_warn_about_useless_cast): Don't warn when a glvalue is cast to a non-reference type. gcc/ChangeLog: * doc/invoke.texi: Update documentation of -Wuseless-cast. gcc/testsuite/ChangeLog: * g++.dg/warn/Wuseless-cast.C: Remove dg-warning. * g++.dg/warn/Wuseless-cast3.C: New test. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead [not found] <bug-85043-4@http.gcc.gnu.org/bugzilla/> ` (3 preceding siblings ...) 2022-10-19 19:30 ` cvs-commit at gcc dot gnu.org @ 2022-10-19 19:32 ` mpolacek at gcc dot gnu.org 2022-10-19 19:36 ` ppalka at gcc dot gnu.org ` (2 subsequent siblings) 7 siblings, 0 replies; 8+ messages in thread From: mpolacek at gcc dot gnu.org @ 2022-10-19 19:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85043 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #16 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Should be fixed now. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead [not found] <bug-85043-4@http.gcc.gnu.org/bugzilla/> ` (4 preceding siblings ...) 2022-10-19 19:32 ` mpolacek at gcc dot gnu.org @ 2022-10-19 19:36 ` ppalka at gcc dot gnu.org 2022-10-24 4:36 ` egallager at gcc dot gnu.org 2022-10-24 16:18 ` mpolacek at gcc dot gnu.org 7 siblings, 0 replies; 8+ messages in thread From: ppalka at gcc dot gnu.org @ 2022-10-19 19:36 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85043 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |13.0 CC| |ppalka at gcc dot gnu.org ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead [not found] <bug-85043-4@http.gcc.gnu.org/bugzilla/> ` (5 preceding siblings ...) 2022-10-19 19:36 ` ppalka at gcc dot gnu.org @ 2022-10-24 4:36 ` egallager at gcc dot gnu.org 2022-10-24 16:18 ` mpolacek at gcc dot gnu.org 7 siblings, 0 replies; 8+ messages in thread From: egallager at gcc dot gnu.org @ 2022-10-24 4:36 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85043 --- Comment #17 from Eric Gallager <egallager at gcc dot gnu.org> --- (In reply to Marek Polacek from comment #16) > Should be fixed now. It seems the fix just silenced the -Wuseless-cast false positive without also adding the separate -Wcast-to-the-same-type flag to cover that case instead; I still think that would be useful. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead [not found] <bug-85043-4@http.gcc.gnu.org/bugzilla/> ` (6 preceding siblings ...) 2022-10-24 4:36 ` egallager at gcc dot gnu.org @ 2022-10-24 16:18 ` mpolacek at gcc dot gnu.org 7 siblings, 0 replies; 8+ messages in thread From: mpolacek at gcc dot gnu.org @ 2022-10-24 16:18 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85043 --- Comment #18 from Marek Polacek <mpolacek at gcc dot gnu.org> --- The casts that are still warned about should really be useless so I don't plan to add another warning. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-10-24 16:18 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <bug-85043-4@http.gcc.gnu.org/bugzilla/> 2022-10-18 13:15 ` [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead mpolacek at gcc dot gnu.org 2022-10-18 13:15 ` mpolacek at gcc dot gnu.org 2022-10-18 13:48 ` mpolacek at gcc dot gnu.org 2022-10-19 19:30 ` cvs-commit at gcc dot gnu.org 2022-10-19 19:32 ` mpolacek at gcc dot gnu.org 2022-10-19 19:36 ` ppalka at gcc dot gnu.org 2022-10-24 4:36 ` egallager at gcc dot gnu.org 2022-10-24 16:18 ` mpolacek at gcc dot gnu.org
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).