This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/37016] [4.3/4.4 Regression] member function pointer failure with optimization



------- Comment #4 from rguenth at gcc dot gnu dot org  2008-08-04 11:54 -------
This is yet another case of the C++ frontend using two different record types
for the same PFN structure.

For example we have

 <component_ref 0x7ffff7ec18c0
...
    arg 0 <var_decl 0x7ffff759c8c0 itemfunptr
        type <record_type 0x7ffff75a5300 sizes-gimplified type_6 BLK
...
    arg 1 <field_decl 0x7ffff759c960 __pfn type <pointer_type 0x7ffff75a56c0>
...
        bit offset <integer_cst 0x7ffff7edc300 constant 0> context <record_type
0x7ffff75a5780>

where you can see the type of the variable indexed is not of the same type
as the field context type of the field we index it by ...

Because TYPE_GET_PTRMEMFUNC_TYPE for itemfun is a different type than the
type of itemfunptr, so we build a "wrong" PTRMEM_CST object.

The following "fixes" this, but I'd like to have a C++ maintainer have a look
here... (there doesn't seem to exist an easy way to fix or workaround this
in SRA, but eventually gimplification of the CONSTRUCTOR could insert a
conversion)

Index: cp/class.c
===================================================================
--- cp/class.c  (revision 138552)
+++ cp/class.c  (working copy)
@@ -6197,7 +6197,7 @@ resolve_address_of_overloaded_function (
     }

   if (TYPE_PTRFN_P (target_type) || TYPE_PTRMEMFUNC_P (target_type))
-    return cp_build_unary_op (ADDR_EXPR, fn, 0, flags);
+    return make_ptrmem_cst (target_type, fn);
   else
     {
       /* The target must be a REFERENCE_TYPE.  Above, cp_build_unary_op


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|rguenth 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=37016


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]