This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: preprocessor/3260: #include __FILE__ broken
- To: neil at gcc dot gnu dot org
- Subject: Re: preprocessor/3260: #include __FILE__ broken
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Date: 21 Jun 2001 20:46:04 -0000
- Cc: gcc-prs at gcc dot gnu dot org,
- Reply-To: Neil Booth <neil at daikokuya dot demon dot co dot uk>
The following reply was made to PR preprocessor/3260; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.demon.co.uk>
To: Andreas Schwab <schwab@suse.de>
Cc: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: preprocessor/3260: #include __FILE__ broken
Date: Thu, 21 Jun 2001 21:42:39 +0100
Andreas Schwab wrote:-
> #include __FILE__ does not work.
> >How-To-Repeat:
> $ cat file.c
> #define PASS 1
> #if PASS == 1
> #undef PASS
> #define PASS 2
> #include __FILE__
> #undef PASS
> #define PASS 3
> #include __FILE__
> #endif
> PASS
> $ gcc -E file.c
> file.c:5:18: file.c__: No such file or directory
> file.c:8:18: file.c__: Success
> # 10 "file.c"
> 3
Fixed with this patch. Curiously, this bug cannot be reproduced with
3.1, because of the changes we made in merging hashtables. That
doesn't detract from the fact that there is a latent bug, though.
Also, the bogosity above where the 2nd error message is "Success" is
already fixed in 3.1. The fix was disruptive, so I didn't put it in
3.0.
Bootstrapped & made check x86 Linux. I'll apply this to branch if and
when we decide about 3.0.1.
Neil.
* cppmacro.c (make_string_token): Null terminate.
Index: cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.52
diff -u -p -r1.52 cppmacro.c
--- cppmacro.c 2001/05/20 06:26:34 1.52
+++ cppmacro.c 2001/06/21 20:37:28
@@ -105,11 +105,12 @@ make_string_token (pool, token, text, le
const U_CHAR *text;
unsigned int len;
{
- U_CHAR *buf = _cpp_pool_alloc (pool, len * 4);
+ U_CHAR *buf = _cpp_pool_alloc (pool, len * 4 + 1);
token->type = CPP_STRING;
token->val.str.text = buf;
token->val.str.len = quote_string (buf, text, len) - buf;
+ token->val.str.text[token->val.str.len] = '\0';
token->flags = 0;
}