From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4755F385782C; Tue, 18 Oct 2022 13:48:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4755F385782C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666100924; bh=MB+WJhmz3x/z7OxEfSQFyoojylN5Pk8V7AM/S+9Ygu0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AUZJlSMn6u4tivorcQC8fNDSWvhXdPfB5Q7RqMTDPuPkz10xjbns7yYXN3iiYgVbJ LnGck5gROzgHUC34crTMLfChBFiWCWw2TaFd0USBWNbCHWluXKNYTXhJCmOtTg5PLQ BriMC0zjt8RX670/n8og9bx2Z/PgmlaYjJbPX9CI= From: "mpolacek at gcc dot 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: Tue, 18 Oct 2022 13:48:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 7.3.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: mpolacek at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D85043 --- Comment #14 from Marek Polacek --- 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 ty= pe.=