------- Comment #4 from ubizjak at gmail dot com 2007-09-04 19:03 ------- (In reply to comment #3)
> Uros, do you think we could, in the fold_convert() switch on TREE_CODE(type), > add a case for RECORD_TYPE similar to VECTOR_TYPE: assert that both > RECORD_TYPEs have the same size, and that their fields correspond one-to-one, > and then create a VIEW_CONVERT_EXPR? Do you think it would be worth having or > would that hurt the middle-end in any way? This is not exactly the part of gcc I'm familiar with (and c never generates RECORD_TYPEs), but I think that this problem should be fixed in fortran/trans-expr.c. At least according to the comment above fold_convert(), this conversion should be handled in front-end convert function. The "patch" below (similar to your proposal, with minimal checking) "works" in the sense that the compilation doesn't break, and generated code doesn't create a black hole at runtime, but I have no idea if it is correct (fortran) transformation. Also, we will break here if sizes are not equal. Index: fold-const.c =================================================================== --- fold-const.c (revision 128092) +++ fold-const.c (working copy) @@ -2616,6 +2616,10 @@ || TREE_CODE (orig) == VECTOR_TYPE); return fold_build1 (VIEW_CONVERT_EXPR, type, arg); + case RECORD_TYPE: + gcc_assert (tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (orig))); + return fold_build1 (VIEW_CONVERT_EXPR, type, arg); + case VOID_TYPE: tem = fold_ignored_result (arg); if (TREE_CODE (tem) == GIMPLE_MODIFY_STMT) > -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33295