call to revolt
Norman Diamond
diamond at jit533.swstokyo.dec.com
Thu Jun 27 10:35:31 AEST 1991
In article <31822 at hydra.gatech.EDU> roy at prism.gatech.EDU (Roy Mongiovi) writes:
>I fail to see why the following should be categorically outlawed:
> char *intptr;
> intptr = malloc(sizeof(int));
This is legal.
> read(fd, intptr, sizeof(int));
This is also legal as far as the standard is concerned. If you don't have
a prototype in scope, and size_t is not the same size of integer as read()
expects for its third parameter, then it could fail at execution time.
> *((int *) intptr)++;
OK, if people want ++ to be applicable to non-lvalues, submit your suggestions
to the committee when they call for comments on C-2001 (the successor to
C-1989). For all you people who enjoy doing:
void f(int x) {
x ++;
}
f(n); /* Huh? Why didn't the value of n get bumped? */
f(3); /* Huh? Why didn't my 3 change to 4, like in the bad old
days of Fortran? */
OK, you should also be allowed to say
(n + 13) ++; /* Huh? Why didn't n get bumped? Or should
(n+13) have been bumped? ? */
*((int *) intptr)++; /* Huh? Why didn't intptr get bumped? */
--
Norman Diamond diamond at tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Permission is granted to feel this signature, but not to look at it.
More information about the Comp.std.c
mailing list