From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A95DD3861027; Tue, 16 Mar 2021 13:55:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A95DD3861027 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99565] [11 Regression] Bogus identical branches warning when returning references to union members Date: Tue, 16 Mar 2021 13:55:27 +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: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc attachments.created 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Mar 2021 13:55:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99565 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek --- Created attachment 50398 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D50398&action=3Dedit gcc11-pr99565.patch If we don't want to warn in this case (I guess pedantically in both C and C= ++ it matters which exact union member is used even when it has the same type, because only one of them can be active, but practically the compiler will t= reat them the same anyway and so they are effectively the same), perhaps we could revert Honza's change for OEP_LEXICOGRAPHIC and use that mode for the COND_= EXPR warnings (where previously it was used just for then/else variant). But, apparently then we warn for some reason twice on: int a; void foo (bool x) { x ? ++a : ++a; } instead of once. Or add some new OEP_ flag that would be used for -Wduplicated-branches?=