This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: off-by-one in get_ident
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: gdr at integrable-solutions dot net (Gabriel Dos Reis)
- Cc: geoffk at geoffk dot org (Geoff Keating), gcc-patches at gcc dot gnu dot org
- Date: Tue, 13 Dec 2005 14:47:44 -0500 (EST)
- Subject: Re: off-by-one in get_ident
>
>
> Hi,
>
> Consider this from c-pch.c:
>
> #define IDENT_LENGTH 8
>
> [...]
>
> /* Compute an appropriate 8-byte magic number for the PCH file, so that
> utilities like file(1) can identify it, and so that GCC can quickly
> ignore non-PCH files and PCH files that are of a completely different
> format. */
>
> static const char *
> get_ident (void)
> {
> static char result[IDENT_LENGTH];
> static const char template[IDENT_LENGTH] = "gpch.013";
>
> The initializer for template is longer (9 characters) than the
> requested length for template. It is mostly harmless in the
> surrounding code, but it breaks compilation with C++ compilers. Which
> of the following fix do you prefer
Why is this invalid C++ but valid C? Again why are you trying to
compile valid C code with a C++ compiler?
-- Pinski