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=unavailable autolearn_force=no version=3.4.4 Path: backlog3.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!us.feeder.erje.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Implicit dereferences rational question Date: Mon, 19 May 2014 18:44:43 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls7.std.com 1400539479 13606 192.74.137.71 (19 May 2014 22:44:39 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 19 May 2014 22:44:39 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:1yS9je9c8nHONSpquQHUB1YC1Pw= Xref: number.nntp.dca.giganews.com comp.lang.ada:186493 Date: 2014-05-19T18:44:43-04:00 List-Id: "Randy Brukardt" writes: > "Victor Porton" wrote in message > news:llb1aa$gth$1@speranza.aioe.org... >> Robert A Duff wrote: >>> Victor Porton writes: >>> >>>> Why implicit dereferences use only access discriminants, not arbitrary >>>> access fields? >>> >>> It helps prevent dangling pointers. >> >> In which way limiting to discriminants may prevent dangling pointers? > > Discriminants have a lengthy set of accessibility rules, which turn out to > be exactly what's needed for limiting dangling pointers. In particular, it's > almost never the case that one can make a copy of an access discriminant, > while that's easy for a "arbitrary access field". Right; thanks, Randy. Victor, I suggest you try to create dangling pointers via those operations that return things with access discriminants. When you see the error messages from the compiler, you will likely understand why it's hard to create dangling pointers by accident. An alternative is to read and understand the accessibility rules. That's quite hard work! And note that a discriminant of a named access type is not an "access discriminant"; the access type has to be anonymous for the special accessibility rules to kick in. - Bob