call to revolt
Craig A. Finseth
fin at norge.unet.umn.edu
Wed Jun 26 23:55:24 AEST 1991
>>Outlawing lvalue casts, however, borders on fascism. I have yet to see
>>a pre-ansi compiler that fails to treat properly
>>
>> void *thing;
>> ((int *)thing)++;
...
>Hi there, I'll die if casting lvals is going to be illegal. Currently I'm
>fiddling and hacking my way into a FORTRAN (Yuck) program, trying to interface
>the beast with loads of old C code. One of my most frequent statements is:
...
Ok, kids, let's take a deep breath and say this one more time. All
together now:
The ANSI standard did not create any new illegal constructs.
The ANSI standard only said, for the first time and in
writing, that certain constructs WHICH NEVER WERE MEANINGFUL
IN THE FIRST PLACE are, in fact, not meaningful.
Yes, some of these constructs may have worked on certain compilers in
certain situations. THAT DOES NOT MEAN THAT THEY EVER WORKED ON ALL
COMPILERS IN ALL SITUATIONS IN THE PAST. The fact that you may have
never bumped into one of these other compilers is irrelevant. The
entire C world is not (pick your favorite) K&R-based, UNIX pcc-based,
IBM PC w/ Turbo C, IBM PC w/Microsoft C, a VAX, ...
So far, no one has come up with any examples of any of these
"meaningful" constructs that are, in fact, meaningful. The recent
examples are:
construct rewrite as
... ((i = 1) == (i = 2)) ... (i = 1, 0) or (i = 2, 0)
q = q++; q = q + 1; or
q += 1; or
q++; or
++q;
void *thing;
((int *)thing)++; (*((int **)(&thing)))++;
[ if you must, that is, and I
hope that I got this right ]
My concluding advice? If you find that you must use a construct like
the one on the left, you should refer to your favorite manual and find
the construct on the right that you really wanted in the first place.
Either that, or put in a comment of the form:
/* The following construct is offically undefined. However,
on system ______ serial number _______ running OS ________
version _______ release ______ configured as _____________
_________________________________ and using compiler
___________ version ________ release ________ with compilation
flags __________ it just happens to work right. For now.
And, by the way, what I mean by "right" is ________________
___________________________________________________________
________________________________________________________ */
Now, do you see how much is gained by having a standard, following it,
and not trying to push the limits too much?
Craig A. Finseth fin at unet.umn.edu [CAF13]
Networking Services +1 612 624 3375 desk
Computer and Information Services +1 612 625 0006 problems
University of Minnesota +1 612 626 1002 FAX
130 Lind Hall, 207 Church St SE
Minneapolis MN 55455-0134, USA
More information about the Comp.std.c
mailing list