C array follies 1
Wayne Throop
throopw at rtp47.UUCP
Sun Sep 15 05:31:33 AEST 1985
> > 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
<the-known-world>!mcnc!rti-sel!rtp47!throopw
More information about the Comp.lang.c
mailing list