From patchwork Fri May 4 12:27:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: : handle size_t /= ptr size in tree-ssa-strlen.c Date: Fri, 04 May 2012 02:27:13 -0000 From: Tristan Gingold X-Patchwork-Id: 156895 Message-Id: To: GCC Patches Cc: Jakub Jelinek Hi, get_string_length assumes that precision of size_t is the same as precision of a pointer, which isn't always true at least on VMS. This patch simply add a conversion in case of mismatch. Tested on ia64/VMS by cross-bootstrapping. Bootstrapped and regtested on i386/GNU Linux. Ok for trunk ? Tristan. 2012-05-04 Tristan Gingold * tree-ssa-strlen.c (get_string_length): Convert lhs if needed. diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index a37633a..bda5ffb 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -427,6 +427,12 @@ get_string_length (strinfo si) NULL); add_referenced_var (lhs_var); tem = gimple_call_arg (stmt, 0); + if (!useless_type_conversion_p (sizetype, TREE_TYPE (lhs))) + { + lhs = convert_to_ptrofftype (lhs); + lhs = force_gimple_operand_gsi (&gsi, lhs, true, NULL_TREE, + true, GSI_SAME_STMT); + } lenstmt = gimple_build_assign_with_ops (POINTER_PLUS_EXPR, make_ssa_name (lhs_var, NULL),