This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: mem stomp in cpplib.c?


bash-2.04$ cat ~/bug.c 
#assert test(answer)
#if #tesz(answer)
#error Not all chars significant!
#endif
bash-2.04$ ./cpp ~/bug.c
# 1 "/home/neil/bug.c"
/home/neil/bug.c:3:2: #error Not all chars significant!


I've committed the following patch as an obvious fix.  I'll add a
test case in the next batch of test cases.

Neil.

	* cpplib.c: (_cpp_parse_assertion):  Perform hash lookups
	based on full length of predicate.

Index: cpplib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplib.c,v
retrieving revision 1.182
diff -u -p -r1.182 cpplib.c
--- cpplib.c	2000/07/05 18:12:42	1.182
+++ cpplib.c	2000/07/06 09:48:08
@@ -1328,7 +1328,7 @@ _cpp_parse_assertion (pfile, answerp)
   /* Prefix '#' to get it out of macro namespace.  */
   sym[0] = '#';
   memcpy (sym + 1, predicate->val.name.text, len);
-  return cpp_lookup (pfile, sym, len);
+  return cpp_lookup (pfile, sym, len + 1);
 
  error:
   FREE_ANSWER (answer);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]