aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1992-10-20 08:57:43 +0000
committerRichard Stallman <rms@gnu.org>1992-10-20 08:57:43 +0000
commit2f145821b7d0956d775bc012722ddc68149ed37d (patch)
tree2bd7b519091ff98859526e1d67acab3f31bbcd48 /gcc/tree.c
parent71bde1f321ed9cb0e5c8289a95bb5d4bce502413 (diff)
downloadgcc-2f145821b7d0956d775bc012722ddc68149ed37d.zip
gcc-2f145821b7d0956d775bc012722ddc68149ed37d.tar.gz
gcc-2f145821b7d0956d775bc012722ddc68149ed37d.tar.bz2
(make_node, copy_node): Don't assume node length is multiple of int.
From-SVN: r2524
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 4fb48e6..1422544 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -877,11 +877,12 @@ make_node (code)
tree_node_sizes[(int)kind] += length;
#endif
- /* We assume here that the length of a tree node is a multiple of the
- size of an int. Rounding up won't work because it would clobber
- the next object. */
+ /* Clear a word at a time. */
for (i = (length / sizeof (int)) - 1; i >= 0; i--)
((int *) t)[i] = 0;
+ /* Clear any extra bytes. */
+ for (i = length / sizeof (int) * sizeof (int); i < length; i++)
+ ((char *) t)[i] = 0;
TREE_SET_CODE (t, code);
if (obstack == &permanent_obstack)
@@ -978,6 +979,9 @@ copy_node (node)
for (i = (length / sizeof (int)) - 1; i >= 0; i--)
((int *) t)[i] = ((int *) node)[i];
+ /* Clear any extra bytes. */
+ for (i = length / sizeof (int) * sizeof (int); i < length; i++)
+ ((char *) t)[i] = 0;
TREE_CHAIN (t) = 0;