[backport from gcc-4.7/trunk, fixes regression from PR47917 patch ] Date: Tue, 15 Mar 2011 12:31:53 +0100 From: Jakub Jelinek Subject: [committed] Fix fallout from snprintf folding patch (PR tree-optimization/48129) List-Archive: Hi! On some targets implicit_built_in_decls[BUILT_IN_SNPRINTF] is NULL, but as we want only the return type of the snprintf function and fold_builtin_snprintf in that case is only used when __builtin_* variant is used explicitly, using built_in_decls is better and avoids the ICE. Bootstrapped/regtested on x86_64-linux and i686-linux, tested on the testcase with cross to cris-elf, committed to trunk as obvious. gcc/ 2011-03-15 Jakub Jelinek PR tree-optimization/48129 * builtins.c (fold_builtin_snprintf): Convert to type of built_in_decls[BUILT_IN_SNPRINTF] retval instead of implicit_built_in_decls[BUILT_IN_SNPRINTF] retval. --- gcc-4.6-20110312/gcc/builtins.c.~1~ 2011-03-16 16:24:51.000000000 +0100 +++ gcc-4.6-20110312/gcc/builtins.c 2011-03-16 16:27:48.000000000 +0100 @@ -12038,9 +12038,8 @@ fold_builtin_snprintf (location_t loc, t if (call && retval) { - retval = fold_convert_loc - (loc, TREE_TYPE (TREE_TYPE (implicit_built_in_decls[BUILT_IN_SNPRINTF])), - retval); + tree fn = built_in_decls[BUILT_IN_SNPRINTF]; + retval = fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fn)), retval); return build2 (COMPOUND_EXPR, TREE_TYPE (retval), call, retval); } else