https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120098
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at redhat dot com,
| |mjambor at suse dot cz
--- Comment #8 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
With modified testcase the conversion happens in forwprop1
void {anonymous}::MultiTermDocs::wrap (struct MultiTermDocs * const this)
{
int (*) () * _1;
int (*) () _2;
int (*) () * _3;
int (*) () _4;
int (*) () * _5;
int (*) () _6;
int (*) () * _7;
int (*) () _8;
int (*) () * _9;
int (*) () _10;
int (*) () * _11;
int (*) () _12;
int (*) () * _13;
int (*) () _14;
int (*) () * _15;
int (*) () _16;
int (*) () * _17;
int (*) () _18;
<bb 2> :
_1 = this_20(D)->_vptr.MultiTermDocs;
_2 = *_1;
OBJ_TYPE_REF(_2;(struct MultiTermDocs)this_20(D)->0B) (this_20(D), 0B);
...
}
So the problem is that we assume that when method is called, this poiner is
already fully constructed.
The following patch fixes the testcase
diff --git a/gcc/ipa-polymorphic-call.cc b/gcc/ipa-polymorphic-call.cc
index 09316de0e6b..7291f6aeb7f 100644
--- a/gcc/ipa-polymorphic-call.cc
+++ b/gcc/ipa-polymorphic-call.cc
@@ -1046,7 +1046,7 @@
ipa_polymorphic_call_context::ipa_polymorphic_call_context (tree fndecl,
else
{
maybe_derived_type = true;
- maybe_in_construction = false;
+ maybe_in_construction = true;
}
if (instance)
{
@@ -1808,7 +1808,7 @@ ipa_polymorphic_call_context::get_dynamic_type (tree
instance,
{
if (!outer_type || tci.seen_unanalyzed_store)
return false;
- if (maybe_in_construction)
+ if (maybe_in_construction && 0)
maybe_in_construction = false;
if (dump_file)
fprintf (dump_file, " No dynamic type change found.\n");
Now I wonder if the testcase is valid? I.e. it is valid to call C::wrap when
the type is already destructed?
If so, the second hunk of the patch will need some love. It is killing most of
the dynamic type analysis