------- Comment #3 from rguenth at gcc dot gnu dot org 2010-03-22 10:30 ------- I get on x86_64-linux
> ./xgcc -B. -flto t1.c t2.c -O2 In file included from t2.c:2:0, from t1.c:2, from :0: t1.c: In function 'main': t1.c:5:22: internal compiler error: in fold_convert_loc, at fold-const.c:2792 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. lto-wrapper: ././xgcc returned 1 exit status collect2: lto-wrapper returned 1 exit status same with the less reduced testcase on x86_64 and i?86 linux. Thanks for the report. This is because we do not merge struct bar {int x;}; and typedef struct{int x;} bar; but we expect to be able to convert them into each other during inlining: #2 0x0000000000c120ac in declare_return_variable (id=0x7fffffffd9d0, return_slot=0x0, modify_dest=0x7ffff5af03c0) at /space/rguenther/src/svn/trunk/gcc/tree-inline.c:2690 2690 use = fold_convert (caller_type, var); (gdb) l 2685 2686 /* Build the use expr. If the return type of the function was 2687 promoted, convert it back to the expected type. */ 2688 use = var; 2689 if (!useless_type_conversion_p (caller_type, TREE_TYPE (var))) 2690 use = fold_convert (caller_type, var); This is really invalid C as bar is re-declared in an incompatible way (which you'd see if you combine both TUs). Now, we shouldn't ICE here anyway and LTO should be forgiving to this kind of errors. The following fixes the symptoms. Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 157619) +++ gcc/tree-inline.c (working copy) @@ -2687,7 +2687,12 @@ declare_return_variable (copy_body_data promoted, convert it back to the expected type. */ use = var; if (!useless_type_conversion_p (caller_type, TREE_TYPE (var))) - use = fold_convert (caller_type, var); + { + if (fold_convertible_p (caller_type, var)) + use = fold_convert (caller_type, var); + else + use = fold_build1 (VIEW_CONVERT_EXPR, caller_type, var); + } STRIP_USELESS_TYPE_CONVERSION (use); -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2010-03-22 10:30:26 date| | Summary|Compiler hang with -O2 -flto|ICE in fold_convert_loc, at | |fold-const.c:2670 with -O2 - | |flto http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43455