call to revolt

J. Horsmeier jos at and.nl
Wed Jun 26 18:39:33 AEST 1991


In article <rabson.677868220 at physics.ubc.ca> rabson at physics.ubc.ca (David Rabson) writes:
[...]
>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)++;
>
>(or, if it doesn't know about voids, the same thing with char *thing).  I
>realize that some machines might, in principle, have different alignments for
>different types of pointers.   A void *, however, I thought, was guaranteed
>to obey the most restrictive alignment and hence be castable to any other
>pointer.
>
>I hereby invite the black-shirts from the ansi camp to explain their
>prejudice against casting lvalues.
[...]
>David Rabson
>Departments of Physics, University of British Columbia and McMaster University

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:

type* Thing;

((int)Thing)= Thing-Base+1;

where Thing points into an array of things and Base is the beginning of the
array, just to change pointers into FORTRAN indices. 
I know this is dirty and things might go into la la land on lots of 
machines, but it works on the machine it's running on now. 
I also know that I can overlay different types with unions. 

But why? Things used to work fine this way (if you know what you're doing). 
I really like the statement: `You get what you deserve'. Here I get what I
want :-) BTW beauty doesn't count when FORTRAN is involved. 

You have my support on this topic!

Jos


+----------------------------------------------------------------------+
|O   J.A. Horsmeier AND Software B.V.        phone : +31 10 4367100   O|
|O                  Westersingel 106/108     fax   : +31 10 4367110   O|
|O                  3015 LD  Rotterdam NL    e-mail: jos at and.nl       O|
|O--------------------------------------------------------------------O|
|O               I am a Hamburger (F. Zappa 1974)                     O|
+----------------------------------------------------------------------+



More information about the Comp.std.c mailing list