This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/33192] __imag operator drops side effects in subexpr
- From: "pinskia at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Aug 2007 09:00:35 -0000
- Subject: [Bug c/33192] __imag operator drops side effects in subexpr
- References: <bug-33192-6809@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from pinskia at gmail dot com 2007-08-26 09:00 -------
Subject: Re: New: __imag operator drops side effects in subexpr
On 26 Aug 2007 05:21:22 -0000, sabre at nondot dot org
<gcc-bugzilla@gcc.gnu.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
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33192