public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable
@ 2006-07-18 10:29 reichelt at gcc dot gnu dot org
2006-07-18 10:34 ` [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing anonymous C99 variable pinskia at gcc dot gnu dot org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-07-18 10:29 UTC (permalink / raw)
To: gcc-bugs
The following valid code snippet triggers an ICE since GCC 4.0.0
(only with the C frontend):
========================================
struct A { int i; };
void foo()
{
((struct A) { 0 }).i += 1;
}
========================================
bug.c: In function 'foo':
bug.c:5: internal compiler error: in gimple_add_tmp_var, at gimplify.c:720
Please submit a full bug report, [etc.]
--
Summary: [4.0/4.1/4.2 regression] ICE incrementing temporary
variable
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code, monitored
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: reichelt at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing anonymous C99 variable
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
@ 2006-07-18 10:34 ` pinskia at gcc dot gnu dot org
2006-07-18 10:39 ` [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing compound literal expression pinskia at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-07-18 10:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-07-18 10:33 -------
First off this "((struct A) { 0 })" is not a temporary variable but instead an
anonymous C99 variable.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Summary|[4.0/4.1/4.2 regression] ICE|[4.0/4.1/4.2 regression] ICE
|incrementing temporary |incrementing anonymous C99
|variable |variable
Target Milestone|--- |4.0.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
2006-07-18 10:34 ` [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing anonymous C99 variable pinskia at gcc dot gnu dot org
@ 2006-07-18 10:39 ` pinskia at gcc dot gnu dot org
2006-07-24 23:16 ` fjahanian at apple dot com
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-07-18 10:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-07-18 10:39 -------
Confirmed, we are gimplifying the compound literal expression twice which in
turn calls gimple_add_tmp_var twice on the decl.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-07-18 10:39:24
date| |
Summary|[4.0/4.1/4.2 regression] ICE|[4.0/4.1/4.2 regression] ICE
|incrementing anonymous C99 |incrementing compound
|variable |literal expression
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
2006-07-18 10:34 ` [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing anonymous C99 variable pinskia at gcc dot gnu dot org
2006-07-18 10:39 ` [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing compound literal expression pinskia at gcc dot gnu dot org
@ 2006-07-24 23:16 ` fjahanian at apple dot com
2006-07-31 23:30 ` mmitchel at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: fjahanian at apple dot com @ 2006-07-24 23:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from fjahanian at apple dot com 2006-07-24 23:16 -------
gcc generates two separate trees for compound literals in c and c++. As in this
test case:
struct S {
int i,j;
};
void foo (struct S);
int main ()
{
foo((struct S){1,1});
}
In c it generates compound_literal_expr and in c++ it generates target_expr.
But gimplifier treats them differently in the following areas:
1) in routine mostly_copy_tree_v we don;t copy target_expr but we do copy
compound_literal_expr. I see the following comment there:
/ * Similar to copy_tree_r() but do not copy SAVE_EXPR or TARGET_EXPR
nodes.
These nodes model computations that should only be done once. If we
were to unshare something like SAVE_EXPR(i++), the gimplification
process would create wrong code. */
Shouldn't compound_literal_expr be treated same as target_expr here?
2) gimplify_target_expr can be called more than once on the same target_expr
node because first time around its TARGET_EXPR_INITIAL is set to NULL.
This works as a guard and prevents its temporary to be added to the
temporary list more than once (when call is made to gimple_add_tmp_var).
On the other hand, such a guard does not exist for a compound_literal_expr
and when gimple_add_tmp_var is called, it asserts. So, I added check for
!DECL_SEEN_IN_BIND_EXPR_P (decl) in gimplify_compound_literal_expr before
call to gimple_add_tmp_var is made. As in the following diff:
% svn diff c-gimplify.c
Index: c-gimplify.c
===================================================================
--- c-gimplify.c (revision 116462)
+++ c-gimplify.c (working copy)
@@ -538,7 +538,7 @@
/* This decl isn't mentioned in the enclosing block, so add it to the
list of temps. FIXME it seems a bit of a kludge to say that
anonymous artificial vars aren't pushed, but everything else is. */
- if (DECL_NAME (decl) == NULL_TREE)
+ if (DECL_NAME (decl) == NULL_TREE && !DECL_SEEN_IN_BIND_EXPR_P (decl))
gimple_add_tmp_var (decl);
This fixes the problem I am encouterring as well as the test case in this PR.
--
fjahanian at apple dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fjahanian at apple dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
` (2 preceding siblings ...)
2006-07-24 23:16 ` fjahanian at apple dot com
@ 2006-07-31 23:30 ` mmitchel at gcc dot gnu dot org
2006-08-18 3:20 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-07-31 23:30 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
` (3 preceding siblings ...)
2006-07-31 23:30 ` mmitchel at gcc dot gnu dot org
@ 2006-08-18 3:20 ` pinskia at gcc dot gnu dot org
2006-08-18 3:42 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-18 3:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2006-08-18 03:20 -------
Wait a minute the C front-end produces for this testcase:
<<< Unknown tree: compound_literal_expr
struct A D.1524 = {.i=0}; >>>
.i = <<< Unknown tree: compound_literal_expr
struct A D.1524 = {.i=0}; >>>
.i + 1;
so obviously we are going to gimplify the compound_literal_expr twice.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
` (4 preceding siblings ...)
2006-08-18 3:20 ` pinskia at gcc dot gnu dot org
@ 2006-08-18 3:42 ` pinskia at gcc dot gnu dot org
2006-08-23 11:23 ` jsm28 at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-18 3:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pinskia at gcc dot gnu dot org 2006-08-18 03:42 -------
for +=/-= we could use PREINCREMENT_EXPR/PREDECREMENT_EXPR trees but for *=,
/=, |=, ^=, we cannot use any of the above.
I wonder if a SAVE_EXPR make this work?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
` (5 preceding siblings ...)
2006-08-18 3:42 ` pinskia at gcc dot gnu dot org
@ 2006-08-23 11:23 ` jsm28 at gcc dot gnu dot org
2006-08-25 21:14 ` jsm28 at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2006-08-23 11:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jsm28 at gcc dot gnu dot org 2006-08-23 11:23 -------
The patch in comment#3 is OK if the testcase is added to gcc.c-torture/compile.
Please post the final patch to gcc-patches.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
` (6 preceding siblings ...)
2006-08-23 11:23 ` jsm28 at gcc dot gnu dot org
@ 2006-08-25 21:14 ` jsm28 at gcc dot gnu dot org
2006-08-25 21:37 ` [Bug c/28418] [4.0/4.1 " fjahanian at apple dot com
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2006-08-25 21:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jsm28 at gcc dot gnu dot org 2006-08-25 21:14 -------
Subject: Bug 28418
Author: jsm28
Date: Fri Aug 25 21:14:24 2006
New Revision: 116436
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116436
Log:
2006-08-25 Fariborz Jahanian <fjahanian@apple.com>
PR c/28418
* c-gimplify.c (gimplify_compound_literal_expr): Don't add
variable again if DECL_SEEN_IN_BIND_EXPR_P.
2006-08-25 Joseph S. Myers <joseph@codesourcery.com>
* gcc.c-torture/compile/compound-literal-1.c: New test.
Added:
trunk/gcc/testsuite/gcc.c-torture/compile/compound-literal-1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-gimplify.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
` (7 preceding siblings ...)
2006-08-25 21:14 ` jsm28 at gcc dot gnu dot org
@ 2006-08-25 21:37 ` fjahanian at apple dot com
2006-08-25 22:52 ` jsm28 at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: fjahanian at apple dot com @ 2006-08-25 21:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from fjahanian at apple dot com 2006-08-25 21:36 -------
I was about to sub mit the patch. Thank you for this patch.
- Fariborz
> Subject: Bug 28418
>
> Author: jsm28
> Date: Fri Aug 25 21:14:24 2006
> New Revision: 116436
>
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116436
> Log:
> 2006-08-25 Fariborz Jahanian <fjahanian@apple.com>
>
> PR c/28418
> * c-gimplify.c (gimplify_compound_literal_expr): Don't add
> variable again if DECL_SEEN_IN_BIND_EXPR_P.
>
> 2006-08-25 Joseph S. Myers <joseph@codesourcery.com>
>
> * gcc.c-torture/compile/compound-literal-1.c: New test.
>
> Added:
> trunk/gcc/testsuite/gcc.c-torture/compile/compound-literal-1.c
> Modified:
> trunk/gcc/ChangeLog
> trunk/gcc/c-gimplify.c
> trunk/gcc/testsuite/ChangeLog
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
` (8 preceding siblings ...)
2006-08-25 21:37 ` [Bug c/28418] [4.0/4.1 " fjahanian at apple dot com
@ 2006-08-25 22:52 ` jsm28 at gcc dot gnu dot org
2006-08-26 0:26 ` jsm28 at gcc dot gnu dot org
2006-08-26 2:35 ` pinskia at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2006-08-25 22:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jsm28 at gcc dot gnu dot org 2006-08-25 22:52 -------
Subject: Bug 28418
Author: jsm28
Date: Fri Aug 25 22:52:40 2006
New Revision: 116446
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116446
Log:
2006-08-25 Fariborz Jahanian <fjahanian@apple.com>
PR c/28418
* c-gimplify.c (gimplify_compound_literal_expr): Don't add
variable again if DECL_SEEN_IN_BIND_EXPR_P.
2006-08-25 Joseph S. Myers <joseph@codesourcery.com>
* gcc.c-torture/compile/compound-literal-1.c: New test.
Added:
branches/gcc-4_1-branch/gcc/testsuite/gcc.c-torture/compile/compound-literal-1.c
- copied unchanged from r116436,
trunk/gcc/testsuite/gcc.c-torture/compile/compound-literal-1.c
Modified:
branches/gcc-4_1-branch/gcc/ChangeLog
branches/gcc-4_1-branch/gcc/c-gimplify.c
branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
` (9 preceding siblings ...)
2006-08-25 22:52 ` jsm28 at gcc dot gnu dot org
@ 2006-08-26 0:26 ` jsm28 at gcc dot gnu dot org
2006-08-26 2:35 ` pinskia at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2006-08-26 0:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jsm28 at gcc dot gnu dot org 2006-08-26 00:25 -------
Subject: Bug 28418
Author: jsm28
Date: Sat Aug 26 00:24:31 2006
New Revision: 116461
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116461
Log:
2006-08-25 Fariborz Jahanian <fjahanian@apple.com>
PR c/28418
* c-gimplify.c (gimplify_compound_literal_expr): Don't add
variable again if DECL_SEEN_IN_BIND_EXPR_P.
testsuite:
2006-08-25 Joseph S. Myers <joseph@codesourcery.com>
* gcc.c-torture/compile/compound-literal-1.c: New test.
Added:
branches/gcc-4_0-branch/gcc/testsuite/gcc.c-torture/compile/compound-literal-1.c
- copied unchanged from r116436,
trunk/gcc/testsuite/gcc.c-torture/compile/compound-literal-1.c
Modified:
branches/gcc-4_0-branch/gcc/ChangeLog
branches/gcc-4_0-branch/gcc/c-gimplify.c
branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/28418] [4.0/4.1 regression] ICE incrementing compound literal expression
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
` (10 preceding siblings ...)
2006-08-26 0:26 ` jsm28 at gcc dot gnu dot org
@ 2006-08-26 2:35 ` pinskia at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-26 2:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from pinskia at gcc dot gnu dot org 2006-08-26 02:34 -------
Fixed.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28418
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2006-08-26 2:35 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-18 10:29 [Bug c/28418] New: [4.0/4.1/4.2 regression] ICE incrementing temporary variable reichelt at gcc dot gnu dot org
2006-07-18 10:34 ` [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing anonymous C99 variable pinskia at gcc dot gnu dot org
2006-07-18 10:39 ` [Bug c/28418] [4.0/4.1/4.2 regression] ICE incrementing compound literal expression pinskia at gcc dot gnu dot org
2006-07-24 23:16 ` fjahanian at apple dot com
2006-07-31 23:30 ` mmitchel at gcc dot gnu dot org
2006-08-18 3:20 ` pinskia at gcc dot gnu dot org
2006-08-18 3:42 ` pinskia at gcc dot gnu dot org
2006-08-23 11:23 ` jsm28 at gcc dot gnu dot org
2006-08-25 21:14 ` jsm28 at gcc dot gnu dot org
2006-08-25 21:37 ` [Bug c/28418] [4.0/4.1 " fjahanian at apple dot com
2006-08-25 22:52 ` jsm28 at gcc dot gnu dot org
2006-08-26 0:26 ` jsm28 at gcc dot gnu dot org
2006-08-26 2:35 ` pinskia 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).