From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29296 invoked by alias); 7 Jan 2015 18:00:12 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 29199 invoked by uid 48); 7 Jan 2015 18:00:05 -0000 From: "dcb314 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/64524] gcc can't detect same expression in both parts of ternary operator Date: Wed, 07 Jan 2015 18:00:00 -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: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dcb314 at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned 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: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg00398.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64524 --- Comment #2 from David Binderman --- (In reply to Jakub Jelinek from comment #1) > Should it complain only when the expressions are the same (e.g. token-wise), > or even when just two different expressions have the same value? > I mean, say: > enum X { E = 5, F = 5 }; > int i = cond ? E : F; > int j = cond ? x + 3 : x + 2 + 1; > int k = cond ? sizeof (x) : sizeof (y); > etc. All would be good ;-> I suspect token-wise comparison would be simple and cheap, so suggest do that first. That would cover my example. I suspect more complex would be making sure two compile time constants have the same value, so suggest do that second. That would cover cases i and k above. Suspect case j would be more difficult, since it involves expression comparison. Suggest leave till last. Feel free to adjust the priority order if my guesses are wrong.