public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/85043] -Wuseless-cast false positive for temporary objects; add separate -Wcast-to-the-same-type to cover that case instead Date: Wed, 19 Oct 2022 19:30:33 +0000 [thread overview] Message-ID: <bug-85043-4-37tFFqMyvL@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-85043-4@http.gcc.gnu.org/bugzilla/> 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.
next prev parent reply other threads:[~2022-10-19 19:30 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top [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 2022-10-18 13:48 ` mpolacek at gcc dot gnu.org 2022-10-19 19:30 ` cvs-commit at gcc dot gnu.org [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-85043-4-37tFFqMyvL@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).