Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!nbires!hao!boulder!sunybcs!rutgers!ucla-cs!zen!ucbvax!decvax!decwrl!pyramid!prls!philabs!micomvax!musocs!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: comp.lang.c Subject: Re: Silly program [was Re: Style [++i vs i++] ] Message-ID: <875@mcgill-vision.UUCP> Date: Sat, 29-Aug-87 23:52:17 EDT Article-I.D.: mcgill-v.875 Posted: Sat Aug 29 23:52:17 1987 Date-Received: Sat, 12-Sep-87 15:48:11 EDT References: <8298@brl-adm.ARPA> <587@cblpe.ATT.COM> <189@xyzzy.UUCP> <5272@utcsri.UUCP> Organization: McGill University, Montreal Lines: 33 In article <5272@utcsri.UUCP>, flaps@utcsri.UUCP (Alan J Rosenthal) writes: > In article <513@ivax.doc.ic.ac.uk> dcw@doc.ic.ac.uk (Duncan C White) writes: >> I think [someone - Duncan said "Alan" but Alan said "not me"] is >> wrong here: if he really wants to add one byte, [well, one char] to >> something that is a 'pointer to [int]' then I guess he should use: >> p = (int *) ( 1 + (char *) p ); Yes. But see below for comments on the wisdom of wanting to do such a thing in the first place. > ...except that when you dereference it you will get an address > exception! No, you *may* get an address exception. On a VAX, for instance (and we all know the whole world is a VAX, right? right? :-), this behaves perfectly nicely. Such unaligned pointers will probably be slightly slower, but they work fine. > Come on here, it is MEANINGLESS to do this kind of operation. No, it is machine- and implementation-dependent, which is not the same thing as meaningless. Doing such a thing (moving an int pointer by one char), except in seriously machine-dependent code, is probably indicative of more serious problems. > It's not just that "adding sizeof(int)" is what you probably want, > it's that it's the only sensible thing to do. No, the only sensible *portable* thing to do. der Mouse (mouse@mcgill-vision.uucp)