This is the mail archive of the gcc-patches@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: 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


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