public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/33192] New: __imag operator drops side effects in subexpr
@ 2007-08-26 5:21 sabre at nondot dot org
2007-08-26 9:00 ` [Bug c/33192] " pinskia at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: sabre at nondot dot org @ 2007-08-26 5:21 UTC (permalink / raw)
To: gcc-bugs
GCC miscompiles this:
int bar();
void foo() {
int X = __imag bar();
}
to not call bar.
-Chris
--
Summary: __imag operator drops side effects in subexpr
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sabre at nondot dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33192
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Bug c/33192] New: __imag operator drops side effects in subexpr
2007-08-26 5:21 [Bug c/33192] New: __imag operator drops side effects in subexpr sabre at nondot dot org
2007-08-26 9:00 ` [Bug c/33192] " pinskia at gmail dot com
@ 2007-08-26 9:00 ` Andrew Pinski
2007-08-26 14:56 ` [Bug c/33192] " rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andrew Pinski @ 2007-08-26 9:00 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/33192] __imag operator drops side effects in subexpr
2007-08-26 5:21 [Bug c/33192] New: __imag operator drops side effects in subexpr sabre at nondot dot org
@ 2007-08-26 9:00 ` pinskia at gmail dot com
2007-08-26 9:00 ` [Bug c/33192] New: " Andrew Pinski
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gmail dot com @ 2007-08-26 9:00 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/33192] __imag operator drops side effects in subexpr
2007-08-26 5:21 [Bug c/33192] New: __imag operator drops side effects in subexpr sabre at nondot dot org
2007-08-26 9:00 ` [Bug c/33192] " pinskia at gmail dot com
2007-08-26 9:00 ` [Bug c/33192] New: " Andrew Pinski
@ 2007-08-26 14:56 ` rguenth at gcc dot gnu dot org
2008-10-16 17:08 ` jsm28 at gcc dot gnu dot org
2008-10-16 17:13 ` jsm28 at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-08-26 14:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2007-08-26 14:56 -------
Confirmed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2007-08-26 14:56:26
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33192
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/33192] __imag operator drops side effects in subexpr
2007-08-26 5:21 [Bug c/33192] New: __imag operator drops side effects in subexpr sabre at nondot dot org
` (2 preceding siblings ...)
2007-08-26 14:56 ` [Bug c/33192] " rguenth at gcc dot gnu dot org
@ 2008-10-16 17:08 ` jsm28 at gcc dot gnu dot org
2008-10-16 17:13 ` jsm28 at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-10-16 17:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jsm28 at gcc dot gnu dot org 2008-10-16 17:07 -------
Subject: Bug 33192
Author: jsm28
Date: Thu Oct 16 17:05:57 2008
New Revision: 141176
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141176
Log:
PR c/33192
* c-typeck.c (build_unary_op): Use omit_one_operand for
IMAGPART_EXPR of real argument.
testsuite:
* gcc.dg/imag-1.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/imag-1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-typeck.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33192
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/33192] __imag operator drops side effects in subexpr
2007-08-26 5:21 [Bug c/33192] New: __imag operator drops side effects in subexpr sabre at nondot dot org
` (3 preceding siblings ...)
2008-10-16 17:08 ` jsm28 at gcc dot gnu dot org
@ 2008-10-16 17:13 ` jsm28 at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-10-16 17:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jsm28 at gcc dot gnu dot org 2008-10-16 17:12 -------
Fixed for 4.4.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33192
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-10-16 17:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-26 5:21 [Bug c/33192] New: __imag operator drops side effects in subexpr sabre at nondot dot org
2007-08-26 9:00 ` [Bug c/33192] " pinskia at gmail dot com
2007-08-26 9:00 ` [Bug c/33192] New: " Andrew Pinski
2007-08-26 14:56 ` [Bug c/33192] " rguenth at gcc dot gnu dot org
2008-10-16 17:08 ` jsm28 at gcc dot gnu dot org
2008-10-16 17:13 ` jsm28 at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).