This is the mail archive of the gcc-patches@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]

[PATCH] Fix PR46866


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2010-12-09  Richard Guenther  <rguenther@suse.de>

	PR middle-end/46844
	* gimple-fold.c (canonicalize_constructor_val): Canonicalize
	addresses.

	* gcc.c-torture/compile/pr46866.c: New testcase.

Index: gcc/gimple-fold.c
===================================================================
*** gcc/gimple-fold.c	(revision 167630)
--- gcc/gimple-fold.c	(working copy)
*************** canonicalize_constructor_val (tree cval)
*** 132,137 ****
--- 132,141 ----
  	return NULL_TREE;
        if (base && TREE_CODE (base) == VAR_DECL)
  	add_referenced_var (base);
+       /* We never have the chance to fixup types in global initializers
+          during gimplification.  Do so here.  */
+       if (TREE_TYPE (TREE_TYPE (cval)) != TREE_TYPE (TREE_OPERAND (cval, 0)))
+ 	cval = build_fold_addr_expr (TREE_OPERAND (cval, 0));
      }
    return cval;
  }
Index: gcc/testsuite/gcc.c-torture/compile/pr46866.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr46866.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr46866.c	(revision 0)
***************
*** 0 ****
--- 1,19 ----
+ extern void *malloc(__SIZE_TYPE__);
+ typedef struct T T;
+ struct T {
+     void (*destroy)(void *);
+ };
+ void destroy(union { void *this; } __attribute__((transparent_union)));
+ static const typeof(destroy) *_destroy  = (const typeof(destroy)*)destroy;
+ void destroy(void *this);
+ static T *create_empty(void)
+ {
+   T *this = malloc(sizeof(*this));
+   *this = (typeof(*this)){ _destroy };
+   return this;
+ }
+ void openssl_crl_load(void)
+ {
+   T *this = create_empty();
+   destroy(this);
+ }


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