Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!adm!ASC::GUTHERY%slb-test.csnet@relay.cs.net From: .csnet"@relay.cs.net> Newsgroups: comp.lang.c Subject: Incrementing after a cast Message-ID: <2029@brl-adm.ARPA> Date: Wed, 24-Dec-86 17:17:50 EST Article-I.D.: brl-adm.2029 Posted: Wed Dec 24 17:17:50 1986 Date-Received: Wed, 24-Dec-86 21:36:31 EST Sender: news@brl-adm.ARPA Lines: 31 Casts are conversions? Oh? You'd never know it looking at the code that out of my C compilers ... including Harbison's! He just regards away. The fact that there are machines which would like to have C compilers on which ((sometype *)p)++ doesn't work as a "regard as" only means that these machines aren't compatible with a lot of people's notion of C's model of computation. There's a whole lot more machines on which ((sometype *)p)++ makes perfect legal, technical, and useful sense and these happen to be C machines. Why lots of people with ordinary machines can't do something useful, intuitive, and natural because some solder-crazed EE somewhere might, just might mind you, someday do something unnatural to his memory system is beyond me. If you insist on being strict, here's a definition of ((sometype *)p)++ which will work on any machine: "Think of the bits refered to as p as a (sometype *). If don't have enough bits or you have too many bits do something reasonable. Now increment the (sometype *) you're thinking of. Now put the results back into p. If you don't have enough bits or you have too many bits, do something reasonable." And no noise please about doing something reasonable because 1) we do it all the time with numbers so why not with pointers too, 2) it's probably what you want any way, and 3) it'll never have to be done on machines that are reasonable to begin with. (By the way there is no reason why ((x+1) = 10) shouldn't work too.) I forsee a day when there are two kinds of C compilers: standard ones and useful ones ... just like Pascal and Fortran. Are we making progress yet?