From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Fri, 11 Feb 2011 11:10:59 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <9a8f406d-05ca-4bf3-8487-918d4e0dd634@o18g2000prh.googlegroups.com> <4d52ee47$0$18057$882e7ee2@usenet-news.net> <4d5306a0$0$18057$882e7ee2@usenet-news.net> <76c123ab-7425-44d8-b26d-b2b41a9aa42b@o7g2000prn.googlegroups.com> <4d5310ab$0$18057$882e7ee2@usenet-news.net> <9bff52ca-6213-41da-8fa4-3a4cdd8086d3@y36g2000pra.googlegroups.com> <4d5315c8$0$18057$882e7ee2@usenet-news.net> <159dca70-2103-46d7-beb2-c7754d30fe36@k15g2000prk.googlegroups.com> <4d53222d$0$18057$882e7ee2@usenet-news.net> <4d540714$0$27423$882e7ee2@usenet-news.net> <4d5423b9$0$27423$882e7ee2@usenet-news.net> <867afa64-090f-48bf-93a3-54ec23b51381@f18g2000yqd.googlegroups.com> In-Reply-To: <867afa64-090f-48bf-93a3-54ec23b51381@f18g2000yqd.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4d555f9a$0$27376$882e7ee2@usenet-news.net> NNTP-Posting-Host: 847b10a4.usenet-news.net X-Trace: DXC==eUdQQ@aII]=GmOQnDdCEP^oXGM_6\KVPmX0AG3X_jU_WonLZPGF:d]VjKk:Lk^BNQcR12TN^Bg7^L= On 2/11/2011 3:26 AM, Ludovic Brenta wrote: > You are wrong because the C program can *also* overflow its stack or > heap and you *also* have to worry about that, just like in Ada; Actually, Ada has the more severe problem here, because Ada makes it easy to declare objects on the stack which are sized based on the values of subprogram parameters, while C and C++ do not. I know I've seen a good number of postings over the years here on c.l.a. where newbies make this mistake - they'll declare some local N�N�N matrix and wonder why their program blows up. The heap is much more forgiving, especially nowadays. > When looking at C code, if you don't constantly ask yourself "hat if > the pointer is null, or the index is out of range?" then I am quite > worried at the resulting quality of your code. That just isn't so. Programs aren't just randomly tossed together bits of code. When someone calls a function, they know what the function expects and call it that way. It's certainly possible to get things wrong, and it's true that the result of such an error will be much more mysterious than in Ada, but it is severely incorrect in C code to go around looking at pointer indirections and adding checks for null. It is simply the case that some routines expect to be called with a non-null pointer, and in C it's the job of the programmer to make sure that is what happens. You may not like this way of working, but it is what it is, and you are not going to convince any C programmer that the function has bugs because it doesn't check. And similarly for array bounds. No one is asking you to abandon Ada for C, but as I said, there are absolutely enormous amounts of correctly working C code in existence, and you need to respect the language and its practitioners enough to recognize that. You might also ask yourself why, if Ada is so good, is it so little used? There was the old canard that C programmers didn't want their pointers and array bounds checked, but since the world took so readily to Java, that doesn't hold water. Maybe it's just that people don't respond well when told "We're going to show you idiots how it *should* be done." It's interesting to read J-P Rosen's . It's full of this kind of attitude, that the designers of Ada have cast pearls before swine.