This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Dodji Seketeli <dodji at redhat dot com>
- Cc: Markus Trippelsdorf <markus at trippelsdorf dot de>, Bernd Edlinger <bernd dot edlinger at hotmail dot de>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Tom Tromey <tromey at redhat dot com>, Manuel López-Ibáñez <lopezibanez at gmail dot com>
- Date: Fri, 24 Jan 2014 17:13:34 +0100
- Subject: Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals
- Authentication-results: sourceware.org; auth=none
- References: <878uwuap4f dot fsf at redhat dot com> <878uwt63e2 dot fsf at redhat dot com> <20131113081610 dot GH27813 at tucnak dot zalov dot cz> <87zjp7t73c dot fsf at redhat dot com> <DUB129-W872C78585B0C16D48CFFA5E4A40 at phx dot gbl> <87vbxcig8t dot fsf at redhat dot com> <20140124150532 dot GB396 at x4> <87iot9qtff dot fsf at redhat dot com> <20140124154419 dot GQ892 at tucnak dot redhat dot com> <878uu5qs3q dot fsf at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Jan 24, 2014 at 05:09:29PM +0100, Dodji Seketeli wrote:
> * input.c (read_line_num): Gracefully handle non-file locations or
> empty caches.
>
> diff --git a/gcc/input.c b/gcc/input.c
> index 547c177..b05e1da 100644
> --- a/gcc/input.c
> +++ b/gcc/input.c
> @@ -600,7 +600,8 @@ static bool
> read_line_num (fcache *c, size_t line_num,
> char ** line, ssize_t *line_len)
> {
> - gcc_assert (line_num > 0);
> + if (!c || line_num < 1)
> + return false;
>
> if (line_num <= c->line_num)
> {
Ok.
> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/cpp/warning-zero-location.c
> @@ -0,0 +1,6 @@
> +/*
> + { dg-options "-D _GNU_SOURCE" }
> + { dg-do compile }
> + */
> +
> +#define _GNU_SOURCE /* { dg-warning "redefined" } */
I doubt this would fail without the patch though, because
fno-diagnostics-show-caret is added by default to flags.
So, I'd say you need also -fdiagnostics-show-caret in dg-options to
reproduce it.
Jakub