summaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-09 03:37:13 +0000
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-09 03:37:13 +0000
commit1922631399748632bd11f749af5a0ec79848cd60 (patch)
treeea418c4c38fd76f73b99d6f70603ffce9b411bec /gcc/builtins.c
parentecdeeb375dbda1a0874c16168c47024f852e1a63 (diff)
downloadgcc-1922631399748632bd11f749af5a0ec79848cd60.tar.gz
* builtins.c (fold_builtin_strncpy): Make sure len is a constant
before comparing it as such. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84343 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c5
1 files changed, 5 insertions, 0 deletions
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);