diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2004-07-09 03:37:13 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@gcc.gnu.org> | 2004-07-09 03:37:13 +0000 |
commit | 691e2db8999df2267f332360bb2603cb7244d7e6 (patch) | |
tree | ea418c4c38fd76f73b99d6f70603ffce9b411bec /gcc/builtins.c | |
parent | 37369edcc9531367872341c4bb074299949910c2 (diff) | |
download | gcc-691e2db8999df2267f332360bb2603cb7244d7e6.zip gcc-691e2db8999df2267f332360bb2603cb7244d7e6.tar.gz gcc-691e2db8999df2267f332360bb2603cb7244d7e6.tar.bz2 |
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
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index ecb7841..11e1f05 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); |