Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site rtp47.UUCP
Path: utzoo!watmath!clyde!bonnie!akgua!mcnc!rti-sel!rtp47!throopw
From: throopw@rtp47.UUCP (Wayne Throop)
Newsgroups: net.lang.c
Subject: Re: C array follies 1
Message-ID: <185@rtp47.UUCP>
Date: Sat, 14-Sep-85 15:31:33 EDT
Article-I.D.: rtp47.185
Posted: Sat Sep 14 15:31:33 1985
Date-Received: Sun, 15-Sep-85 23:55:09 EDT
References: <171@rtp47.UUCP> <10299@ucbvax.ARPA> <179@rtp47.UUCP> <2793@sun.uucp>
Organization: Data General, RTP, NC
Lines: 33

> > the formal declaration
> >         int x[3];
> > should make sizeof(x) == (sizeof(int) * 3).
>
> An alternative is simply to forbid such a formal declaration.
> ...
>         foo() { int x[3]; x++; }
> is illegal.  [and thus by analogy the formal should be made illegal]
>                       Guy Harris

I agree that this is better than the current situation.  Interestingly
enough, while lint raises not a peep in the following example for b, our
local typechecker has something different to say about this:

    1   void f(a,b)
    2       int *a, b[];
    3   {
    4       int *c, d[1];
    5       ++a;
    6       ++b;
    7       ++c;
    8       ++d;
    9   }

    #1017 6  not an lvalue (:IDENTIFIER b :AUTO ... )
    #1017 8  not an lvalue (:IDENTIFIER d :AUTO ... )

therefore, my code already obeys this restriction.  I also try to
remember to declare formal arrays as pointers always.  However, I
still think that if formal arrays are to be allowed, they "ought to"
have the sizeof properties I outlined before.
-- 
Wayne Throop at Data General, RTP, NC
!mcnc!rti-sel!rtp47!throopw