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 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 Path: g2news2.google.com!postnews.google.com!v11g2000prb.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Pascal Calling Convention Date: Mon, 28 Mar 2011 14:16:28 -0700 (PDT) Organization: http://groups.google.com Message-ID: <330393be-cb82-4cd8-ba44-6e59af7b75bf@v11g2000prb.googlegroups.com> References: <9b04626e-567d-408c-aab3-39b964b3ffd6@l2g2000prg.googlegroups.com> <4d90efdd$1$14806$882e7ee2@usenet-news.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301346988 18139 127.0.0.1 (28 Mar 2011 21:16:28 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 28 Mar 2011 21:16:28 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v11g2000prb.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19521 Date: 2011-03-28T14:16:28-07:00 List-Id: On Mar 28, 1:29=A0pm, Hyman Rosen wrote: > On 3/26/2011 4:46 PM, Robert A Duff wrote: > > > It doesn't seem reasonable to me. =A0Uninitialized variables do not > > contain random data. =A0They contain arbitrary data. =A0And it's quite > > likely that such arbitrary data happens to be the same every time, > > or has some other non-random pattern. =A0Bad 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: I hope your "favorite data structure" comment was sarcastic. I would expect this code to behave incorrectly a large portion of the time; specifically, if I read the code right, once you add any element to the set, the program is likely to think 0 is in the set whether you've added it or not. -- Adam > template > class set > { > =A0 =A0 =A0unsigned n; =A0 =A0// number of members in set > =A0 =A0 =A0unsigned d[N]; // members are in d[0..n-1] > =A0 =A0 =A0unsigned s[N]; // d[s[k]] =3D=3D k if k is a member > =A0 =A0 =A0// unspecified elements of d and s are arbitrary > > public: > =A0 =A0 =A0set() : n(0) { } > =A0 =A0 =A0bool has(unsigned k) > =A0 =A0 =A0 =A0 =A0{ return k < N && s[k] < n && d[s[k]] =3D=3D k; } > =A0 =A0 =A0void add(unsigned k) > =A0 =A0 =A0 =A0 =A0{ if (k < N && !has(k)) { d[n] =3D k; s[k] =3D n++; } > =A0 =A0 =A0void del(unsigned k) > =A0 =A0 =A0 =A0 =A0{ if (has(k)) { unsigned i =3D s[k]; d[i] =3D d[--n]; = s[d[i]] =3D i; } > =A0 =A0 =A0void clr() { n =3D 0; } > > > > };