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,2cb1f0b6d642e1dc X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!s09-10.readnews.com!not-for-mail Date: Mon, 28 Mar 2011 16:29:25 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Pascal Calling Convention References: <9b04626e-567d-408c-aab3-39b964b3ffd6@l2g2000prg.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4d90efdd$1$14806$882e7ee2@usenet-news.net> NNTP-Posting-Host: 5b3080e6.usenet-news.net X-Trace: DXC=8XMXQ0GLI9WC3?BJ\<]\aXQFZ3T]GPM]WmX0AG3X_jU_QeV^edQ8]5\i22nWOTKLQSMcWTcYQB@PQ5JTBH_kUBGQ4eKgJTdYJ On 3/26/2011 4:46 PM, Robert A Duff wrote: > It doesn't seem reasonable to me. Uninitialized variables do not > contain random data. They contain arbitrary data. And it's quite > likely that such arbitrary data happens to be the same every time, > or has some other non-random pattern. Bad Guys sometimes exploit > such patterns to cause security problems. Time for my favorite data structure! This is a structure which represents an unordered set of the integers [0,N) and which has constant time initialization, insertion, deletion, and membership test. It relies on reading uninitialized data as some arbitrary value. Compilers which regard doing this as undefined behavior will break the code. I'm going to write it in C++, but it should be straightforward to translate to Ada: template class set { unsigned n; // number of members in set unsigned d[N]; // members are in d[0..n-1] unsigned s[N]; // d[s[k]] == k if k is a member // unspecified elements of d and s are arbitrary public: set() : n(0) { } bool has(unsigned k) { return k < N && s[k] < n && d[s[k]] == k; } void add(unsigned k) { if (k < N && !has(k)) { d[n] = k; s[k] = n++; } void del(unsigned k) { if (has(k)) { unsigned i = s[k]; d[i] = d[--n]; s[d[i]] = i; } void clr() { n = 0; } };