Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!uw-june!uw-entropy!dataio!bright From: bright@Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c Subject: Re: Efficient coding considered harmful? Message-ID: <1732@dataio.Data-IO.COM> Date: 31 Oct 88 19:30:47 GMT Article-I.D.: dataio.1732 References: <3105@hubcap.UUCP> <34112@XAIT.XEROX.COM> <1700@dataio.Data-IO.COM> <8775@smoke.BRL.MIL> <7421@ihlpl.ATT.COM> Reply-To: bright@dataio.Data-IO.COM (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 13 In article <7421@ihlpl.ATT.COM> knudsen@ihlpl.ATT.COM (Knudsen) writes: >In article <8775@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn ) writes: >> (But don't write something like >> for (p = &a[j]; --p >= a; ) >> which is nonportable.) >Why not portable? If a was created by a call to malloc, and (sizeof(a[0])>2), then on the 8086 in large memory model, p can NEVER be less than a! The trouble results from malloc creating a segment for a. Decrementing p past a causes a segment wrap, exactly like decrementing an unsigned variable past 0. This behavior is allowed for by ANSI C, and is the most reasonable way of doing things on the 8086.