* Infinite loop with -include and -M
@ 2003-04-22 0:41 Andreas Schwab
2003-04-22 22:08 ` Neil Booth
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Schwab @ 2003-04-22 0:41 UTC (permalink / raw)
To: gcc
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
Andreas.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Infinite loop with -include and -M
2003-04-22 0:41 Infinite loop with -include and -M Andreas Schwab
@ 2003-04-22 22:08 ` Neil Booth
0 siblings, 0 replies; 2+ messages in thread
From: Neil Booth @ 2003-04-22 22:08 UTC (permalink / raw)
To: Andreas Schwab; +Cc: gcc
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);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-04-22 19:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-22 0:41 Infinite loop with -include and -M Andreas Schwab
2003-04-22 22:08 ` Neil Booth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).