This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[c++] Fix invalid type conversion in vtable constructors
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org, rguenther at suse dot de, mark at codesourcery dot com
- Date: Thu, 9 Sep 2010 15:50:31 +0200
- Subject: [c++] Fix invalid type conversion in vtable constructors
Hi,
fixing constant folding on array constructors with implicit indexes leads to
problem with C++ frontend producing wrong ADDR_EXPR in constructors of vtables.
ADDR_EXPR type is vfunc_ptr_type_node while the METHOD_DECL within ADDR_EXPR
has type corresponding to the partiuclar virtual function.
This patch adds the missing NOP_EXPR to avoid ICE with the folding patch i
would like to submit.
Bootstrapped/regtested x86_64-linux, OK?
Honza
PR tree-optimization/45605
* cp/class.c (build_vtbl_initializer): Avoid wrong type conversion in ADDR_EXPR
Index: cp/class.c
===================================================================
--- cp/class.c (revision 164080)
+++ cp/class.c (working copy)
@@ -7797,7 +7797,8 @@ build_vtbl_initializer (tree binfo,
{
fn = abort_fndecl;
if (abort_fndecl_addr == NULL)
- abort_fndecl_addr = build1 (ADDR_EXPR, vfunc_ptr_type_node, fn);
+ abort_fndecl_addr = fold_convert (vfunc_ptr_type_node,
+ build_fold_addr_expr (fn));
init = abort_fndecl_addr;
}
else
@@ -7810,7 +7810,7 @@ build_vtbl_initializer (tree binfo,
}
/* Take the address of the function, considering it to be of an
appropriate generic type. */
- init = build1 (ADDR_EXPR, vfunc_ptr_type_node, fn);
+ init = fold_convert (vfunc_ptr_type_node, build_fold_addr_expr (fn));
}
}