diff options
author | Jeffrey A Law <law@cygnus.com> | 1999-10-31 07:54:56 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 1999-10-31 01:54:56 -0600 |
commit | f5d236de11b9276e2573043083e279489289d246 (patch) | |
tree | bc5866b7ac6979c4d4dca84d20e8967695641095 /gcc/cccp.c | |
parent | 0d9009fd94a333be02f9843edaf649d8f1b289bd (diff) | |
download | gcc-f5d236de11b9276e2573043083e279489289d246.zip gcc-f5d236de11b9276e2573043083e279489289d246.tar.gz gcc-f5d236de11b9276e2573043083e279489289d246.tar.bz2 |
cccp.c (macroexpand): Avoid out of range accesses for omitted arguments.
* cccp.c (macroexpand): Avoid out of range accesses for omitted
arguments.
From-SVN: r30289
Diffstat (limited to 'gcc/cccp.c')
-rw-r--r-- | gcc/cccp.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -8581,7 +8581,12 @@ macroexpand (hp, op) Also count number of times each arg is used. */ xbuf_len = defn->length; for (ap = defn->pattern; ap != NULL; ap = ap->next) { - if (ap->stringify) + if (ap->stringify && args[ap->argno].stringified_length_bound == 0) + /* macarg is not called for omitted arguments, as a result + stringified_length_bound will be zero. We need to make + enough space for "". */ + xbuf_len += 2; + else if (ap->stringify) xbuf_len += args[ap->argno].stringified_length_bound; else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional) /* Add 4 for two newline-space markers to prevent |