* [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O
[not found] <bug-45699-4@http.gcc.gnu.org/bugzilla/>
@ 2010-09-29 18:43 ` rguenth at gcc dot gnu.org
2010-10-06 15:46 ` bredelin at ucla dot edu
` (8 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-09-29 18:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Priority|P3 |P1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O
[not found] <bug-45699-4@http.gcc.gnu.org/bugzilla/>
2010-09-29 18:43 ` [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O rguenth at gcc dot gnu.org
@ 2010-10-06 15:46 ` bredelin at ucla dot edu
2010-10-08 12:12 ` jamborm at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: bredelin at ucla dot edu @ 2010-10-06 15:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699
--- Comment #5 from bredelin at ucla dot edu 2010-10-06 15:46:08 UTC ---
This bug still existed as of Oct 4, 2010.
gcc version 4.6.0 20101004 (experimental) [trunk revision 164952] (Ubuntu
20101004-0ubuntu1)
After this bug is fixed, I'll be able to do some more testing of 4.6 for a
large c++ program.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O
[not found] <bug-45699-4@http.gcc.gnu.org/bugzilla/>
2010-09-29 18:43 ` [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O rguenth at gcc dot gnu.org
2010-10-06 15:46 ` bredelin at ucla dot edu
@ 2010-10-08 12:12 ` jamborm at gcc dot gnu.org
2010-10-08 14:41 ` jamborm at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: jamborm at gcc dot gnu.org @ 2010-10-08 12:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699
--- Comment #6 from Martin Jambor <jamborm at gcc dot gnu.org> 2010-10-08 12:12:34 UTC ---
The problem seems to be the only folding of OBJ_TYPE_REF we do and
which comes from a (copy) constructor. So I assume this is the same
issue as PR 45934.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O
[not found] <bug-45699-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2010-10-08 12:12 ` jamborm at gcc dot gnu.org
@ 2010-10-08 14:41 ` jamborm at gcc dot gnu.org
2010-10-08 15:59 ` bredelin at ucla dot edu
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: jamborm at gcc dot gnu.org @ 2010-10-08 14:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699
--- Comment #7 from Martin Jambor <jamborm at gcc dot gnu.org> 2010-10-08 14:40:41 UTC ---
Please disregard the previous comment, I saw what I wanted to see and
not what was actually there. But it is true that avoiding the only
O_T_R folding avoids the segfault. But so far I see nothing wrong
with that devirtualization... I will keep staring at it for a bit
longer.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O
[not found] <bug-45699-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2010-10-08 14:41 ` jamborm at gcc dot gnu.org
@ 2010-10-08 15:59 ` bredelin at ucla dot edu
2010-10-08 16:37 ` bredelin at ucla dot edu
` (4 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: bredelin at ucla dot edu @ 2010-10-08 15:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699
--- Comment #8 from bredelin at ucla dot edu 2010-10-08 15:58:49 UTC ---
When you say segfault, I presume you mean abort?
When I use the debugger, the problem appears to be in the call to
new Parameters(*P);
On x86_64, the problem occurs as follows: (x86_32 is different)
In the copy constructor, Parameters::SuperModel2 is constructed OK.
Then the copy constructor for Parameters::Probability_Model is called,
which calls the copy constructor for Probability_Model::Model2, which
calls the copy constructor for Model2::vector<double>.
In the (synthesized) copy constructor
vector<double>::vector<double>(const vector<double>& __x),
the debugger claims that "this" and "__x" are both optimized out, and won't let
me inspect anything.
The SIGABORT actually occurs because the __x has a __x.size() of
18446726482060379005. It should have a size of 0.
(I can't call __x.size(), but I can access __n, which is initialized from
__x.size()).
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O
[not found] <bug-45699-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2010-10-08 15:59 ` bredelin at ucla dot edu
@ 2010-10-08 16:37 ` bredelin at ucla dot edu
2010-10-08 16:51 ` jamborm at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: bredelin at ucla dot edu @ 2010-10-08 16:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699
--- Comment #9 from bredelin at ucla dot edu 2010-10-08 16:37:15 UTC ---
On x86_32, the problem occurs somewhat differently. All I did differently is
add "-m32".
It seems that on x86_32, the copy constructor
vector<int>::vector<int>(const vector& __x)
for SuperModel2::object fails, whereas it succeeded on x86_64. The values for
"this" and "__x" are not optimized out for SuperModel2::object, so they can be
inspected.
The values for __x appear to be crazy. This leads to a large __n, and thus
another abort because of an attempt to allocate too much memory. (__n should be
0). The error may be caused by the fact that &__x points to the wrong memory
location (0xffffd4a0, instead of the correct value 0xffffd484).
I think the location of __x is wrong on x86_64 also, but it just so happens on
x86_64 that __x._M_finish - __x._M_start is 0 for the wrong location of __x,
whereas on x86_32 it does not happen to be 0.
Does this help any?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O
[not found] <bug-45699-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2010-10-08 16:37 ` bredelin at ucla dot edu
@ 2010-10-08 16:51 ` jamborm at gcc dot gnu.org
2010-10-08 17:57 ` jamborm at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: jamborm at gcc dot gnu.org @ 2010-10-08 16:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699
--- Comment #10 from Martin Jambor <jamborm at gcc dot gnu.org> 2010-10-08 16:51:19 UTC ---
I think I know what is going on. BINFO_VIRTUALS of the BINFO
describing Probability_Model within Parameters pint to a wring thunk
of the method Parameters:clone().
Therefore when the call is devirtualized, the this parameter is not
adjusted to point to the whole Ptr object and points only to the part
representing the Probability_Model ancestor. And so all references to
the fields of the object just load garbage.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O
[not found] <bug-45699-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2010-10-08 16:51 ` jamborm at gcc dot gnu.org
@ 2010-10-08 17:57 ` jamborm at gcc dot gnu.org
2010-10-11 18:45 ` jamborm at gcc dot gnu.org
2010-10-11 18:46 ` jamborm at gcc dot gnu.org
9 siblings, 0 replies; 14+ messages in thread
From: jamborm at gcc dot gnu.org @ 2010-10-08 17:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699
--- Comment #11 from Martin Jambor <jamborm at gcc dot gnu.org> 2010-10-08 17:57:11 UTC ---
Created attachment 21998
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=21998
proposed patch
But fortunately BINFOs contain the delta and so we can find the
appropriate thunk in the call graph.
I'm attaching an untested proposed fix which seems to work on the
testcase. Obviously I need to clean it up a little bit and will also
try to make a simple testcase.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O
[not found] <bug-45699-4@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2010-10-08 17:57 ` jamborm at gcc dot gnu.org
@ 2010-10-11 18:45 ` jamborm at gcc dot gnu.org
2010-10-11 18:46 ` jamborm at gcc dot gnu.org
9 siblings, 0 replies; 14+ messages in thread
From: jamborm at gcc dot gnu.org @ 2010-10-11 18:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699
--- Comment #12 from Martin Jambor <jamborm at gcc dot gnu.org> 2010-10-11 18:45:28 UTC ---
Author: jamborm
Date: Mon Oct 11 18:45:23 2010
New Revision: 165327
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165327
Log:
2010-10-11 Martin Jambor <mjambor@suse.cz>
PR middle-end/45699
* gimple-fold.c (gimple_fold_obj_type_ref_known_binfo): Choose among
thunks.
* testsuite/g++.dg/torture/pr45699.C: New test.
* testsuite/g++.dg/otr-fold-1.C: Adjusted.
* testsuite/g++.dg/otr-fold-1.C: Likewise.
Added:
trunk/gcc/testsuite/g++.dg/torture/pr45699.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/gimple-fold.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/otr-fold-1.C
trunk/gcc/testsuite/g++.dg/otr-fold-2.C
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O
[not found] <bug-45699-4@http.gcc.gnu.org/bugzilla/>
` (8 preceding siblings ...)
2010-10-11 18:45 ` jamborm at gcc dot gnu.org
@ 2010-10-11 18:46 ` jamborm at gcc dot gnu.org
9 siblings, 0 replies; 14+ messages in thread
From: jamborm at gcc dot gnu.org @ 2010-10-11 18:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699
Martin Jambor <jamborm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #13 from Martin Jambor <jamborm at gcc dot gnu.org> 2010-10-11 18:46:34 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 14+ messages in thread