* [Bug c++/56961] Segfault with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
@ 2013-04-15 7:45 ` pinskia at gcc dot gnu.org
2013-04-15 7:50 ` [Bug c++/56961] stack overflow in gimplifier " pinskia at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-04-15 7:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|ICE: cycle between |Segfault with volatile
|do_spec_1() / |field
|process_brace_body() / |
|handle_braces() |
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-04-15 07:45:37 UTC ---
Note the backtrace that is provided is the one from gcc where it is executing
cc1plus which is nothing special.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
2013-04-15 7:45 ` [Bug c++/56961] Segfault with volatile field pinskia at gcc dot gnu.org
@ 2013-04-15 7:50 ` pinskia at gcc dot gnu.org
2013-04-15 8:01 ` dimhen at gmail dot com
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-04-15 7:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-invalid-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-04-15
Summary|Segfault with volatile |stack overflow in
|field |gimplifier with volatile
| |field
Ever Confirmed|0 |1
Known to fail| |4.7.0, 4.8.0, 4.9.0
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-04-15 07:50:53 UTC ---
Confirmed.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
2013-04-15 7:45 ` [Bug c++/56961] Segfault with volatile field pinskia at gcc dot gnu.org
2013-04-15 7:50 ` [Bug c++/56961] stack overflow in gimplifier " pinskia at gcc dot gnu.org
@ 2013-04-15 8:01 ` dimhen at gmail dot com
2014-01-06 19:33 ` dimhen at gmail dot com
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dimhen at gmail dot com @ 2013-04-15 8:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
--- Comment #3 from Dmitry G. Dyachenko <dimhen at gmail dot com> 2013-04-15 08:01:24 UTC ---
gcc-4.7.2 / Fedora 18 FAIL too
gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
` (2 preceding siblings ...)
2013-04-15 8:01 ` dimhen at gmail dot com
@ 2014-01-06 19:33 ` dimhen at gmail dot com
2014-06-05 12:16 ` paolo.carlini at oracle dot com
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dimhen at gmail dot com @ 2014-01-06 19:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
--- Comment #4 from Dmitry G. Dyachenko <dimhen at gmail dot com> ---
FAIL
gcc version 4.9.0 20140106 (experimental) [trunk revision 206356] (GCC)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
` (3 preceding siblings ...)
2014-01-06 19:33 ` dimhen at gmail dot com
@ 2014-06-05 12:16 ` paolo.carlini at oracle dot com
2014-06-05 12:29 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-06-05 12:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
I think this is another manifestation of the issue discussed in cp-gimplify.c:
/* Remove any copies of empty classes. We check that the RHS
has a simple form so that TARGET_EXPRs and non-empty
CONSTRUCTORs get reduced properly, and we leave the return
slot optimization alone because it isn't a copy (FIXME so it
shouldn't be represented as one).
Also drop volatile variables on the RHS to avoid infinite
recursion from gimplify_expr trying to load the value. */
note that it happens only when struct foo is empty...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
` (4 preceding siblings ...)
2014-06-05 12:16 ` paolo.carlini at oracle dot com
@ 2014-06-05 12:29 ` rguenth at gcc dot gnu.org
2014-06-05 12:33 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-05 12:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
The C++ gimplify langhook gimplifies the gimplifier generated
vol.1 = b.fields
as
vol.1, b.fields;
so it isn't a manifestation of the issue but a fallout of the attempt to
fix it in the C++ gimplifier... it drops the assignment but leaves the
load from the volatile in place (as side-effect to be preserved?). But
then we gimplify that again ... producing vol.2 = b.fields ... and on we go.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
` (5 preceding siblings ...)
2014-06-05 12:29 ` rguenth at gcc dot gnu.org
@ 2014-06-05 12:33 ` rguenth at gcc dot gnu.org
2014-06-05 12:35 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-05 12:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
I suggest
Index: gcc/cp/cp-gimplify.c
===================================================================
--- gcc/cp/cp-gimplify.c (revision 211262)
+++ gcc/cp/cp-gimplify.c (working copy)
@@ -630,18 +630,8 @@ cp_gimplify_expr (tree *expr_p, gimple_s
Also drop volatile variables on the RHS to avoid infinite
recursion from gimplify_expr trying to load the value. */
if (!TREE_SIDE_EFFECTS (op1)
- || (DECL_P (op1) && TREE_THIS_VOLATILE (op1)))
+ || TREE_THIS_VOLATILE (op1))
*expr_p = op0;
- else if (TREE_CODE (op1) == MEM_REF
- && TREE_THIS_VOLATILE (op1))
- {
- /* Similarly for volatile MEM_REFs on the RHS. */
- if (!TREE_SIDE_EFFECTS (TREE_OPERAND (op1, 0)))
- *expr_p = op0;
- else
- *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
- TREE_OPERAND (op1, 0), op0);
- }
else
*expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
op0, op1);
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
` (6 preceding siblings ...)
2014-06-05 12:33 ` rguenth at gcc dot gnu.org
@ 2014-06-05 12:35 ` rguenth at gcc dot gnu.org
2014-06-05 12:39 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-05 12:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #7)
> I suggest
>
> Index: gcc/cp/cp-gimplify.c
> ===================================================================
> --- gcc/cp/cp-gimplify.c (revision 211262)
> +++ gcc/cp/cp-gimplify.c (working copy)
> @@ -630,18 +630,8 @@ cp_gimplify_expr (tree *expr_p, gimple_s
> Also drop volatile variables on the RHS to avoid infinite
> recursion from gimplify_expr trying to load the value. */
> if (!TREE_SIDE_EFFECTS (op1)
> - || (DECL_P (op1) && TREE_THIS_VOLATILE (op1)))
> + || TREE_THIS_VOLATILE (op1))
> *expr_p = op0;
> - else if (TREE_CODE (op1) == MEM_REF
> - && TREE_THIS_VOLATILE (op1))
> - {
> - /* Similarly for volatile MEM_REFs on the RHS. */
> - if (!TREE_SIDE_EFFECTS (TREE_OPERAND (op1, 0)))
> - *expr_p = op0;
> - else
> - *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
> - TREE_OPERAND (op1, 0), op0);
> - }
> else
> *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
> op0, op1);
This might of course drop arbitrary side-effects of op1 such as
a volatile load from a.b[foo()] where foo () would be dropped.
So it isn't really correct.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
` (7 preceding siblings ...)
2014-06-05 12:35 ` rguenth at gcc dot gnu.org
@ 2014-06-05 12:39 ` rguenth at gcc dot gnu.org
2014-06-05 14:16 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-05 12:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #8)
> (In reply to Richard Biener from comment #7)
> > I suggest
> >
> > Index: gcc/cp/cp-gimplify.c
> > ===================================================================
> > --- gcc/cp/cp-gimplify.c (revision 211262)
> > +++ gcc/cp/cp-gimplify.c (working copy)
> > @@ -630,18 +630,8 @@ cp_gimplify_expr (tree *expr_p, gimple_s
> > Also drop volatile variables on the RHS to avoid infinite
> > recursion from gimplify_expr trying to load the value. */
> > if (!TREE_SIDE_EFFECTS (op1)
> > - || (DECL_P (op1) && TREE_THIS_VOLATILE (op1)))
> > + || TREE_THIS_VOLATILE (op1))
> > *expr_p = op0;
> > - else if (TREE_CODE (op1) == MEM_REF
> > - && TREE_THIS_VOLATILE (op1))
> > - {
> > - /* Similarly for volatile MEM_REFs on the RHS. */
> > - if (!TREE_SIDE_EFFECTS (TREE_OPERAND (op1, 0)))
> > - *expr_p = op0;
> > - else
> > - *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
> > - TREE_OPERAND (op1, 0), op0);
> > - }
> > else
> > *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
> > op0, op1);
>
> This might of course drop arbitrary side-effects of op1 such as
> a volatile load from a.b[foo()] where foo () would be dropped.
>
> So it isn't really correct.
The following should preserve those.
Index: gcc/cp/cp-gimplify.c
===================================================================
--- gcc/cp/cp-gimplify.c (revision 211262)
+++ gcc/cp/cp-gimplify.c (working copy)
@@ -629,18 +629,14 @@ cp_gimplify_expr (tree *expr_p, gimple_s
Also drop volatile variables on the RHS to avoid infinite
recursion from gimplify_expr trying to load the value. */
- if (!TREE_SIDE_EFFECTS (op1)
- || (DECL_P (op1) && TREE_THIS_VOLATILE (op1)))
+ if (!TREE_SIDE_EFFECTS (op1))
*expr_p = op0;
- else if (TREE_CODE (op1) == MEM_REF
- && TREE_THIS_VOLATILE (op1))
+ else if (TREE_THIS_VOLATILE (op1)
+ && (REFERENCE_CLASS_P (op1) || DECL_P (op1)))
{
- /* Similarly for volatile MEM_REFs on the RHS. */
- if (!TREE_SIDE_EFFECTS (TREE_OPERAND (op1, 0)))
- *expr_p = op0;
- else
- *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
- TREE_OPERAND (op1, 0), op0);
+ *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
+ op0, build_fold_addr_expr (op1));
+
}
else
*expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
` (8 preceding siblings ...)
2014-06-05 12:39 ` rguenth at gcc dot gnu.org
@ 2014-06-05 14:16 ` paolo.carlini at oracle dot com
2014-06-05 17:35 ` paolo at gcc dot gnu.org
2014-06-05 17:36 ` paolo.carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-06-05 14:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |paolo.carlini at oracle dot com
Target Milestone|--- |4.10.0
--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Handling it.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
` (9 preceding siblings ...)
2014-06-05 14:16 ` paolo.carlini at oracle dot com
@ 2014-06-05 17:35 ` paolo at gcc dot gnu.org
2014-06-05 17:36 ` paolo.carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo at gcc dot gnu.org @ 2014-06-05 17:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
--- Comment #11 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Thu Jun 5 17:34:48 2014
New Revision: 211286
URL: http://gcc.gnu.org/viewcvs?rev=211286&root=gcc&view=rev
Log:
/cp
2014-06-05 Richard Biener <rguenther@suse.de>
Paolo Carlini <paolo.carlini@oracle.com>
PR c++/56961
* cp-gimplify.c (cp_gimplify_expr, [MODIFY_EXPR]): Rework
handling of empty classes.
/testsuite
2014-06-05 Richard Biener <rguenther@suse.de>
Paolo Carlini <paolo.carlini@oracle.com>
PR c++/56961
* g++.dg/parse/pr56961.C: New.
Added:
trunk/gcc/testsuite/g++.dg/parse/pr56961.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/cp-gimplify.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/56961] stack overflow in gimplifier with volatile field
2013-04-15 7:39 [Bug c++/56961] New: cycle between do_spec_1() / process_brace_body() / handle_braces() dimhen at gmail dot com
` (10 preceding siblings ...)
2014-06-05 17:35 ` paolo at gcc dot gnu.org
@ 2014-06-05 17:36 ` paolo.carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-06-05 17:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Assignee|paolo.carlini at oracle dot com |unassigned at gcc dot gnu.org
--- Comment #12 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed for 4.10.0.
^ permalink raw reply [flat|nested] 13+ messages in thread