Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!ginosko!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: Out-of-bounds pointers Message-ID: <11255@smoke.BRL.MIL> Date: 11 Oct 89 06:26:01 GMT References: <1009@mtxinu.UUCP> <12570028@hpclwjm.HP.COM> <868@crdos1.crd.ge.COM> <11232@smoke.BRL.MIL> <976@crdos1.crd.ge.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 34 In article <976@crdos1.crd.ge.COM> davidsen@crdos1.UUCP (bill davidsen) writes: > Ptr = &ShortVect[-30000]; There are so many implementation assumptions required to make this work that it really cannot be considered sane portable programming practice. >I submit that this is neither sloppy programming or >meaningless, and that it is "not illegal" by K&R 1st Ed. I disagree on both counts. > That's certainly keeping the discussion on a high technical plane. Matters of surprise, unreliability, etc. are hardly very technical. > Please identify the machines in question and quantify the saving. No. I'll conduct my argument on my own terms, thank you very much. > Prevailing practice means what it says, that before compilers were >modified to make it illegal such code would work on most machines, such >as Sun, Vax, PC, Cray, PDP-11, etc. I think that fairly represents at >least 80% of the machines and users running pre-ANSI C. Nobody "modified compilers to make it illegal". The Standard simply makes it clearer than it may have previously been that you're asking for trouble when you write such code. On some implementations it will work all the time, on others it will work some of the time, and on others it will never work. That's due to variations in computer architecture, and to require that such dubious practice be made to work in ALL cases as you seem to expect it to would burden some implementations for insufficient reason. (Plus it would be exceedingly difficult to specify such behavior in the Standard; we had a hard enough time getting the wording for last+1 right.)