public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15853] New: temporaries are not destroyed and overwritten later
@ 2004-06-06 18:43 bugzilla at little-bat dot de
2004-06-06 18:54 ` [Bug rtl-optimization/15853] [3.3 Regression] " pinskia at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: bugzilla at little-bat dot de @ 2004-06-06 18:43 UTC (permalink / raw)
To: gcc-bugs
when initialilizing static data, then temporaries which were required for
automatic type casting are not destroyed. later-on the stack/heap overwrites them.
example source file can be found at
<http://k1.dyndns.org/Develop/projects/gcc-error>
test.cpp example source file which reproduces the error
output-BUMMER.txt output printed by test program when broken
output-OK.txt output printed by test program when ok
a.out FC2 i386 binary, hopefully the broken version B-)
used command line:
bash$ gcc -Wall -O2 -lstdc++ test.cpp // fails
bash$ gcc -Wall -lstdc++ test.cpp // ok
see also short summary at start of source file.
the error only shows up under certain circumstances. e.g. in this case no "-O2"
is ok and when destructor and/or creator are inlined it seemed ok too. then the
destructor was called. see output printed by test program.
this bug report form has no file upload section, which i find very confusing.
just wanted to say that too.
... kio !
--
Summary: temporaries are not destroyed and overwritten later
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bugzilla at little-bat dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: gcc-Version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/15853] [3.3 Regression] temporaries are not destroyed and overwritten later
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
@ 2004-06-06 18:54 ` pinskia at gcc dot gnu dot org
2004-06-07 19:11 ` bugzilla at little-bat dot de
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-06 18:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-06 18:54 -------
Confirmed, a regression from 3.0.4. Note it works in 3.4.0 and 3.5.0.
Also note that -O2 -fno-inline -fno-gcse -fno-strict-aliasing also fails so it has nothing to do with
inlining. Also -O1 -fno-inline passes.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Component|c++ |rtl-optimization
Ever Confirmed| |1
Keywords| |wrong-code
Known to fail| |3.3.3
Known to work| |3.4.0 3.5.0 3.0.4
Last reconfirmed|0000-00-00 00:00:00 |2004-06-06 18:54:47
date| |
Summary|temporaries are not |[3.3 Regression] temporaries
|destroyed and overwritten |are not destroyed and
|later |overwritten later
Target Milestone|--- |3.3.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/15853] [3.3 Regression] temporaries are not destroyed and overwritten later
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
2004-06-06 18:54 ` [Bug rtl-optimization/15853] [3.3 Regression] " pinskia at gcc dot gnu dot org
@ 2004-06-07 19:11 ` bugzilla at little-bat dot de
2004-06-11 22:21 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bugzilla at little-bat dot de @ 2004-06-07 19:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bugzilla at little-bat dot de 2004-06-07 19:11 -------
The conclusion that it has nothing to do with inlining is wrong: the error
occured with not-inlined member functions and adding -fno-inline to the
command line is just a nop. :-)
I tested a version of the test proggi where constructor & destructor are
inlined:
gcc -Wall -O2 -lstdc++ test-inlined.cpp -> a.out ok
gcc -Wall -O2 -lstdc++ -fno-inline test-inlined.cpp -> a.out BUMMER
gcc -Wall -O1 -lstdc++ -fno-inline test-inlined.cpp -> a.out ok
see <http://k1.dyndns.org/Develop/projects/gcc-error>
... kio !
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/15853] [3.3 Regression] temporaries are not destroyed and overwritten later
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
2004-06-06 18:54 ` [Bug rtl-optimization/15853] [3.3 Regression] " pinskia at gcc dot gnu dot org
2004-06-07 19:11 ` bugzilla at little-bat dot de
@ 2004-06-11 22:21 ` pinskia at gcc dot gnu dot org
2004-09-28 13:44 ` gdr at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-11 22:21 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.3.4 |3.3.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/15853] [3.3 Regression] temporaries are not destroyed and overwritten later
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
` (2 preceding siblings ...)
2004-06-11 22:21 ` pinskia at gcc dot gnu dot org
@ 2004-09-28 13:44 ` gdr at gcc dot gnu dot org
2005-01-23 14:50 ` ebotcazou at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: gdr at gcc dot gnu dot org @ 2004-09-28 13:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at gcc dot gnu dot org 2004-09-28 13:33 -------
Adjust milestone
--
What |Removed |Added
----------------------------------------------------------------------------
Known to work|3.4.0 4.0 3.0.4 |3.4.0 4.0.0 3.0.4
Target Milestone|3.3.5 |3.3.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/15853] [3.3 Regression] temporaries are not destroyed and overwritten later
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
` (3 preceding siblings ...)
2004-09-28 13:44 ` gdr at gcc dot gnu dot org
@ 2005-01-23 14:50 ` ebotcazou at gcc dot gnu dot org
2005-01-24 7:53 ` ebotcazou at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2005-01-23 14:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ebotcazou at gcc dot gnu dot org 2005-01-23 14:49 -------
A sibcall problem, hence the workaround -O2 -fno-optimize-sibling-calls.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |ebotcazou at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/15853] [3.3 Regression] temporaries are not destroyed and overwritten later
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
` (4 preceding siblings ...)
2005-01-23 14:50 ` ebotcazou at gcc dot gnu dot org
@ 2005-01-24 7:53 ` ebotcazou at gcc dot gnu dot org
2005-01-24 11:27 ` ebotcazou at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2005-01-24 7:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ebotcazou at gcc dot gnu dot org 2005-01-24 07:53 -------
Fixing.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |ebotcazou at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/15853] [3.3 Regression] temporaries are not destroyed and overwritten later
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
` (5 preceding siblings ...)
2005-01-24 7:53 ` ebotcazou at gcc dot gnu dot org
@ 2005-01-24 11:27 ` ebotcazou at gcc dot gnu dot org
2005-01-25 16:42 ` ebotcazou at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2005-01-24 11:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ebotcazou at gcc dot gnu dot org 2005-01-24 11:27 -------
Um... first of all, this works on 3.4 branch only by accident, i.e. I think the
underlying problem is still present there. What happens is that a call has an
argument containing a TARGET_EXPR with cleanups and is eligible for the sibling
call optimization. The cleanups are expanded during the first pass but, since
the optimization eventually fails, the RTL is thrown away. Then, during the
second pass, the TARGET_EXPR is expanded again but not the cleanups because they
are not registered (the variable 'cleanups' is NULL at expr.c:9050).
I'm not sure how this is supposed to work. Richard, do you have any
recollection of this? In 2000(!), you commited this patch:
Index: calls.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/calls.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- calls.c 17 Mar 2000 22:40:43 -0000 1.97
+++ calls.c 20 Mar 2000 22:40:50 -0000 1.98
@@ -2020,7 +2020,8 @@
safe_for_reeval = 0;
if (optimize >= 2
&& currently_expanding_call == 1
- && stmt_loop_nest_empty ())
+ && stmt_loop_nest_empty ()
+ && ! any_pending_cleanups (1))
{
/* Verify that each argument is safe for re-evaluation. */
for (p = actparms; p; p = TREE_CHAIN (p))
@@ -2152,6 +2153,12 @@
|| ! FUNCTION_OK_FOR_SIBCALL (fndecl))
continue;
+ /* We know at this point that there are not currently any
+ pending cleanups. If, however, in the process of evaluating
+ the arguments we were to create some, we'll need to be
+ able to get rid of them. */
+ expand_start_target_temps ();
+
/* State variables we need to save and restore between
iterations. */
save_pending_stack_adjust = pending_stack_adjust;
@@ -2925,6 +2932,14 @@
if (args[i].aligned_regs)
free (args[i].aligned_regs);
+ if (pass == 0)
+ {
+ /* Undo the fake expand_start_target_temps we did earlier. If
+ there had been any cleanups created, we've already set
+ sibcall_failure. */
+ expand_end_target_temps ();
+ }
+
insns = get_insns ();
end_sequence ();
which is responsible for expanding the cleanups right after the first pass.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |rth at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/15853] [3.3 Regression] temporaries are not destroyed and overwritten later
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
` (6 preceding siblings ...)
2005-01-24 11:27 ` ebotcazou at gcc dot gnu dot org
@ 2005-01-25 16:42 ` ebotcazou at gcc dot gnu dot org
2005-04-28 8:23 ` gdr at gcc dot gnu dot org
2005-04-30 13:44 ` gdr at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2005-01-25 16:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From ebotcazou at gcc dot gnu dot org 2005-01-25 16:42 -------
Stepping down for now.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|ebotcazou at gcc dot gnu dot|unassigned at gcc dot gnu
|org |dot org
Status|ASSIGNED |NEW
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/15853] [3.3 Regression] temporaries are not destroyed and overwritten later
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
` (7 preceding siblings ...)
2005-01-25 16:42 ` ebotcazou at gcc dot gnu dot org
@ 2005-04-28 8:23 ` gdr at gcc dot gnu dot org
2005-04-30 13:44 ` gdr at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: gdr at gcc dot gnu dot org @ 2005-04-28 8:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at gcc dot gnu dot org 2005-04-28 08:23 -------
(In reply to comment #6)
> Um... first of all, this works on 3.4 branch only by accident, i.e. I think the
> underlying problem is still present there. What happens is that a call has an
> argument containing a TARGET_EXPR with cleanups and is eligible for the sibling
> call optimization. The cleanups are expanded during the first pass but, since
> the optimization eventually fails, the RTL is thrown away. Then, during the
> second pass, the TARGET_EXPR is expanded again but not the cleanups because they
> are not registered (the variable 'cleanups' is NULL at expr.c:9050).
>
> I'm not sure how this is supposed to work. Richard, do you have any
> recollection of this? In 2000(!), you commited this patch:
RTH --
I guess you did not have interest in this? Shall I close it as WONTFIX?
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/15853] [3.3 Regression] temporaries are not destroyed and overwritten later
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
` (8 preceding siblings ...)
2005-04-28 8:23 ` gdr at gcc dot gnu dot org
@ 2005-04-30 13:44 ` gdr at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: gdr at gcc dot gnu dot org @ 2005-04-30 13:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at gcc dot gnu dot org 2005-04-30 13:44 -------
Chnages to fix this bug would happen in the middle=end which is risky at
this point. Therefore it won't be fixed for 3.3.6. It fixed in 3.4.0 though.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|3.3.6 |3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15853
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-04-30 13:44 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-06 18:43 [Bug c++/15853] New: temporaries are not destroyed and overwritten later bugzilla at little-bat dot de
2004-06-06 18:54 ` [Bug rtl-optimization/15853] [3.3 Regression] " pinskia at gcc dot gnu dot org
2004-06-07 19:11 ` bugzilla at little-bat dot de
2004-06-11 22:21 ` pinskia at gcc dot gnu dot org
2004-09-28 13:44 ` gdr at gcc dot gnu dot org
2005-01-23 14:50 ` ebotcazou at gcc dot gnu dot org
2005-01-24 7:53 ` ebotcazou at gcc dot gnu dot org
2005-01-24 11:27 ` ebotcazou at gcc dot gnu dot org
2005-01-25 16:42 ` ebotcazou at gcc dot gnu dot org
2005-04-28 8:23 ` gdr at gcc dot gnu dot org
2005-04-30 13:44 ` gdr 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).