From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4485 invoked by alias); 26 Aug 2007 09:00:33 -0000 Received: (qmail 3412 invoked by uid 22791); 26 Aug 2007 09:00:27 -0000 X-Spam-Check-By: sourceware.org Received: from nz-out-0506.google.com (HELO nz-out-0506.google.com) (64.233.162.230) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 26 Aug 2007 09:00:23 +0000 Received: by nz-out-0506.google.com with SMTP id s1so947313nze for ; Sun, 26 Aug 2007 02:00:21 -0700 (PDT) Received: by 10.142.52.9 with SMTP id z9mr462138wfz.1188118821298; Sun, 26 Aug 2007 02:00:21 -0700 (PDT) Received: by 10.142.81.5 with HTTP; Sun, 26 Aug 2007 02:00:21 -0700 (PDT) Message-ID: Date: Sun, 26 Aug 2007 09:00:00 -0000 From: "Andrew Pinski" To: gcc-bugzilla@gcc.gnu.org Subject: Re: [Bug c/33192] New: __imag operator drops side effects in subexpr Cc: gcc-bugs@gcc.gnu.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-IsSubscribed: yes 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: 2007-08/txt/msg01895.txt.bz2 On 26 Aug 2007 05:21:22 -0000, sabre at nondot dot org wrote: > to not call bar. The problem is in c-typeck.c (build_unary_op) (around line 2986). the code looks like: if (TREE_CODE (arg) == COMPLEX_CST) return TREE_IMAGPART (arg); else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE) return fold_build1 (IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg); else return convert (TREE_TYPE (arg), integer_zero_node); So there is no check for TREE_SIDE_EFFECTS. Maybe it should use omit_one_operand or build a COMPOUND_EXPR. Either one will fix the bug. -- Pinski