From 691e2db8999df2267f332360bb2603cb7244d7e6 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Fri, 9 Jul 2004 03:37:13 +0000 Subject: [PATCH] builtins.c (fold_builtin_strncpy): Make sure len is a constant before comparing it as such. * builtins.c (fold_builtin_strncpy): Make sure len is a constant before comparing it as such. From-SVN: r84343 --- gcc/ChangeLog | 5 +++++ gcc/builtins.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bfeb09aeab3..04f778f7bcc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-07-09 Alexandre Oliva + + * builtins.c (fold_builtin_strncpy): Make sure len is a constant + before comparing it as such. + 2004-07-08 Richard Henderson * builtins.c (std_gimplify_va_arg_expr): Hoist valist into a diff --git a/gcc/builtins.c b/gcc/builtins.c index ecb7841ec6d..11e1f05a0f9 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -7385,6 +7385,11 @@ fold_builtin_strncpy (tree exp, tree slen) if (integer_zerop (len)) return omit_one_operand (TREE_TYPE (exp), dest, src); + /* We can't compare slen with len as constants below if len is not a + constant. */ + if (len == 0 || TREE_CODE (len) != INTEGER_CST) + return 0; + if (!slen) slen = c_strlen (src, 1); -- 2.30.2