]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cccp.c (macroexpand): Avoid out of range accesses for omitted arguments.
authorJeffrey A Law <law@cygnus.com>
Sun, 31 Oct 1999 07:54:56 +0000 (07:54 +0000)
committerJeff Law <law@gcc.gnu.org>
Sun, 31 Oct 1999 07:54:56 +0000 (01:54 -0600)
* cccp.c (macroexpand): Avoid out of range accesses for omitted
arguments.

From-SVN: r30289

gcc/ChangeLog
gcc/cccp.c

index c2b522c6cfe47628e46a0acec994895e42f58b14..48c96144b9f3b96d021298b20214059def623744 100644 (file)
@@ -1,3 +1,8 @@
+Sun Oct 31 01:53:30 1999  Jeffrey A Law  (law@cygnus.com)
+
+       * cccp.c (macroexpand): Avoid out of range accesses for omitted
+       arguments.
+
 Sat Oct 30 22:42:50 1999  Stephen L Moshier <moshier@mediaone.net>
 
        * c-lex.c (yylex): Accept 'f' in mantissa of hex float constant.
index 6f9c36cddb794199c81eb8f203406a8b6389ce63..0e77a91ed4e1c04e68af03fddcfaf57e41e55a8c 100644 (file)
@@ -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