This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Projects for beginners
- To: neil at daikokuya dot demon dot co dot uk
- Subject: Re: Projects for beginners
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Thu, 8 Mar 2001 14:43:38 -0500 (EST)
- Cc: gcc at gcc dot gnu dot org, jsm28 at cam dot ac dot uk, zackw at Stanford dot EDU
> From: Neil Booth <neil@daikokuya.demon.co.uk>
>
> Kaveh R. Ghazi wrote:-
>
> > 1. Is this (within reason) possible?
>
> Certainly.
>
> > 2. Do ya'll think it's worthwhile?
>
> Not really. We have enough historical baggage in CPP as it is.
> Neil.
Fair enough.
But in the mean time, as I toyed with implementing it myself, I
realized that the current "poison" behaves exactly as I wanted for the
new feature. Apparently Zack's description about it triggering on
macros was wrong.
E.g. try compiling the following with the latest sources.
----cut here----
extern void *malloc(__SIZE_TYPE__);
#define memcpy bcopy
#define strdup(x) strcpy(malloc(strlen(x)+1), x) /* e.g. */
#pragma GCC poison bcopy malloc
void foo(void)
{
char foo[20], bar[20];
int baz = sizeof(foo);
strdup(foo);
memcpy(foo, bar, baz);
bcopy(foo, bar, baz);
malloc(baz);
#define memcpy bcopy
}
----cut here----
I get:
foo.c:15:3: attempt to use poisoned "bcopy"
foo.c:16:3: attempt to use poisoned "malloc"
foo.c:18:16: attempt to use poisoned "bcopy"
I.e. no warnings for calling strdup or memcpy whose definition contain
the poisoned tokens!
Now is this a bug or a feature? :-)
--Kaveh
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions