This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Infinite loop with -include and -M


Andreas Schwab wrote:-

> When preprocessing a file with -M (or any other option that sets
> flag_no_output) and there is a -include file the preprocessor enters
> an infinite loop in preprocess_file because pfile->buffer->prev never
> becomes NULL, and eventually the process runs out of memory.
> 
> $ echo > included.c
> $ echo > included.h
> $ gcc -include included.h -M included.c

Thanks, fixed thus.

Neil.

	* cpplex.c (_cpp_get_fresh_line): Pop the buffer if return_at_eof.

Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplex.c,v
retrieving revision 1.228
diff -u -p -r1.228 cpplex.c
--- cpplex.c	22 Apr 2003 19:28:00 -0000	1.228
+++ cpplex.c	22 Apr 2003 19:49:45 -0000
@@ -714,14 +714,14 @@ _cpp_get_fresh_line (pfile)
 			       "no newline at end of file");
 	}
  
+      if (!buffer->prev)
+	return false;
+
       if (buffer->return_at_eof)
 	{
-	  buffer->return_at_eof = false;
+	  _cpp_pop_buffer (pfile);
 	  return false;
 	}
-
-      if (!buffer->prev)
-	return false;
 
       _cpp_pop_buffer (pfile);
     }


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