From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19902 invoked by alias); 20 Feb 2012 18:30:29 -0000 Received: (qmail 19893 invoked by uid 22791); 20 Feb 2012 18:30:28 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Feb 2012 18:30:15 +0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52299] GCC warns on compile time division by zero erroneously Date: Mon, 20 Feb 2012 19:20: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-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-02/txt/msg01994.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52299 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #9 from Jakub Jelinek 2012-02-20 18:27:46 UTC --- case COND_EXPR: return build_x_conditional_expr (RECUR (TREE_OPERAND (t, 0)), RECUR (TREE_OPERAND (t, 1)), RECUR (TREE_OPERAND (t, 2)), complain); For this we'd need to first RECUR (TREE_OPERAND (t, 0)), remember that result in some temporary, and look if it is 0, non-zero or unknown. If 0, maybe increment temporarily c_inhibit_evaluation_warnings around RECUR (TREE_OPERAND (t, 1)) (dunno about cp_unevaluated_operand or fold_*defer_overflow_warnings ()), if non-zero similarly for RECUR (TREE_OPERAND (t, 1)).