This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Evil 'typedef x = foo' example.
- To: egcs-bugs at cygnus dot com
- Subject: Evil 'typedef x = foo' example.
- From: Geoffrey KEATING <geoffk at discus dot anu dot edu dot au>
- Date: Mon, 8 Mar 1999 19:06:12 +1100 (EST)
When I try to compile the following, gcc stops with
/home/geoffk/lib/gcc-lib/powerpc-unknown-linux-gnulibc1/egcs-2.91.60/cc1 /tmp/ccq0FKvL.i -quiet -dumpbase z.c -Wall -version -o /tmp/ccCUSX8q.s
GNU C version egcs-2.91.60 19981201 (egcs-1.1.1 release) (powerpc-unknown-linux-gnulibc1) compiled by GNU C version egcs-2.91.60 19981201 (egcs-1.1.1 release).
z.c:4: warning: initialization from incompatible pointer type
z.c:5: warning: initialization from incompatible pointer type
z.c:6: warning: initialization from incompatible pointer type
z.c: In function `main':
z.c:11: invalid type argument of `unary *'
Now, OK, I admit that this is a nasty example. I think, though,
that either the initial typedef should be an error, or the whole
thing should work. It's similar to
struct foo { struct foo * nxt; } a = { &a };
It would be useful to have it work, because then you could finally
declare a proper prototype for functions that return pointers to
functions like themselves:
typedef chaining_func = (chaining_func (*)(void))0;
--
Geoff Keating <Geoff.Keating@anu.edu.au>
===File /tmp/x.c============================================
typedef x = ((x *)0);
x a;
x b = &a;
x c = &b;
x d = &c;
int
main(void)
{
if (**d != b)
abort();
exit(0);
}
============================================================