------- Comment #10 from hubicka at ucw dot cz 2006-11-30 14:04 ------- Subject: Re: [4.3 Regression] ICE in cp_expr_size, at cp/cp-objcp-common.c:101
Hi, the problem is conversion of: __builtin_memcpy(this,&f,sizeof(FIND_RESULT)); to assignment. It triggers sanity check in cp-objcp-common.c that things of this nature are not initialized directly by backend. I am not quite sure if such a check is neccesarily needed and I think in such an side cases it is correct to silently accept the code (it has undefined behaviour anyway, right?) as proposed in the patch. Alternatively we can come up with some alternate way. What however worries me too is why this look is needed at first place. How does langhook.expr_size differ from TYPE_SIZE_UNIT? Perhaps the memcpy folder needs to be expanded to use TYPE_SIZE_UNIT too? Honza * cp-objcp-common.c (cp_expr_size): Do not sanity check that size of certain classes does not matter. Index: cp/cp-objcp-common.c =================================================================== *** cp/cp-objcp-common.c (revision 119360) --- cp/cp-objcp-common.c (working copy) *************** cp_expr_size (tree exp) *** 79,105 **** if (CLASS_TYPE_P (type)) { - /* The backend should not be interested in the size of an expression - of a type with both of these set; all copies of such types must go - through a constructor or assignment op. */ - gcc_assert (!TYPE_HAS_COMPLEX_INIT_REF (type) - || !TYPE_HAS_COMPLEX_ASSIGN_REF (type) - /* But storing a CONSTRUCTOR isn't a copy. */ - || TREE_CODE (exp) == CONSTRUCTOR - /* And, the gimplifier will sometimes make a copy of - an aggregate. In particular, for a case like: - - struct S { S(); }; - struct X { int a; S s; }; - X x = { 0 }; - - the gimplifier will create a temporary with - static storage duration, perform static - initialization of the temporary, and then copy - the result. Since the "s" subobject is never - constructed, this is a valid transformation. */ - || CP_AGGREGATE_TYPE_P (type)); - /* This would be wrong for a type with virtual bases, but they are caught by the assert above. */ return (is_empty_class (type) --- 79,84 ---- -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30017