[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Buiding binutils 2.17 (needs dynamic arrays).

From: Rob Landley
Subject: Re: [Tinycc-devel] Buiding binutils 2.17 (needs dynamic arrays).
Date: Wed, 3 Oct 2007 22:49:44 -0500
User-agent: KMail/1.9.6

On Wednesday 03 October 2007 2:28:17 am Antti-Juhani Kaijanaho wrote:
> On Wed, Oct 03, 2007 at 02:12:27AM -0500, Rob Landley wrote:
> > P.S.  I'm still boggling you can do "int a[42], b(char *c);"  But
> > apparently, yes you can.
> Sure you can.  Of course, I wouldn't allow any of my students write
> stuff like that :)
> > Unfortunately, in tcc you can _also_ do:
> >   int blah(char a)(char b);
> > And it happily takes it.  (I note that gcc has a specific error for this.
> >  Of course gcc has a specific error for everything.)
> That's, I *think* declaring a function that returns a function.  Yes,
> there should be an error message :)

I can't see what case needs post_type() to recurse after a function 
declaration.  After an array, yes.

Considering that "array of function pointer" syntax is:

  int (*wubba[42])(char *a);

That's still not a valid postfix on a function declaration...

This doesn't solve int *wubba[42](char *a) ...

Ok, I redid the code in that area, split post_type() into two new functions, 
and checked in the result...

> > Sigh.  So...  many... corner... cases...!
> The standard is useful in that it tells you how to handle (most) of them
> :)

The draft standard I have is 1.5 megabytes of ascii text (ok, html) that reads 
like it was written by lawyers.  I use it to break ties, not as an 
implementation guide.

The reason nobody's apparently noticed that tcc doesn't complain about a 
function returning a function before is because when you feed it legal code 
it works.  Making it complain properly when fed illegal code is a luxury, 
which I'll implement if it doesn't bloat it too much.

Either way, you feed it bad code, you get bad behavior.  An error message is 
just more easily diagnosed bad behavior.

"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]