This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR preprocessor/15167
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Eric Botcazou <ebotcazou at libertysurf dot fr>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 05 Dec 2004 11:25:14 -0800
- Subject: Re: [PATCH] Fix PR preprocessor/15167
- References: <200412051828.30377.ebotcazou@libertysurf.fr>
Eric Botcazou <ebotcazou@libertysurf.fr> writes:
> Hi,
>
> This is a regression on the mainline and 3.4 branch related to #pragma once.
> The compiler segfaults when a #pragma-onced header is included from two
> different directories (e.g. parent and child directory).
>
> The segfault occurs because f->buffer is NULL when memcmp is invoked in
> should_stack_file here
>
> if ((import || f->once_only)
> && f->err_no == 0
> && f->st.st_mtime == file->st.st_mtime
> && f->st.st_size == file->st.st_size
> && read_file (pfile, f)
> /* Size might have changed in read_file(). */
> && f->st.st_size == file->st.st_size
> && !memcmp (f->buffer, file->buffer, f->st.st_size))
> break;
>
> although read_file was invoked on f. The problem originates in
> _cpp_pop_file_buffer, which doesn't reset f->buffer_valid.
I think f->buffer_valid is supposed to be reset by _cpp_stack_file.
How did it get this far with buffer_valid true?
> Bootstrapped/regtested on amd64-mandrake-linux-gnu. No testcase
> because it is made up of 5 files. OK for mainline and 3.4 branch?
You're allowed to create a test case made up of five files (and/or
directories) if you need to. Several tests in gcc.dg/cpp are already
like that. And it would help me review this if you showed an example,
so that I could see how this was happening.
zw