From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:ac8:598a:0:b0:3de:b5fa:dbad with SMTP id e10-20020ac8598a000000b003deb5fadbadmr5612340qte.5.1682407838417; Tue, 25 Apr 2023 00:30:38 -0700 (PDT) X-Received: by 2002:a25:7396:0:b0:b95:31a3:9d89 with SMTP id o144-20020a257396000000b00b9531a39d89mr5870878ybc.2.1682407838220; Tue, 25 Apr 2023 00:30:38 -0700 (PDT) Path: eternal-september.org!news.eternal-september.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 25 Apr 2023 00:30:37 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=87.143.122.5; posting-account=3zVVBwoAAAC7BSMfgNP7DSbqU9urpt40 NNTP-Posting-Host: 87.143.122.5 References: <6aa39f27-62ca-4486-9fc7-1c713da5b098n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9a1c3ba5-d5ae-41d3-9eab-2b8cd941bc66n@googlegroups.com> Subject: Re: strange cursor in nested containers From: Mario Blunk Injection-Date: Tue, 25 Apr 2023 07:30:38 +0000 Content-Type: text/plain; charset="UTF-8" Xref: news.eternal-september.org comp.lang.ada:65136 List-Id: > > How could I solve the problem ? Not using "rename" ? Using an aliased access type as John Barnes suggests in Ada2005 on page 275 ? > You have to avoid calling Element. Since you have a cursor, you can call > Query_Element, which should pass the actual element to the procedure you supply. Right, that solves the problem. For those interested please find a comparison here: 1. The demo with a dangling (dangerous) cursor: https://github.com/Blunk-electronic/ada_training/blob/master/src/containers/demo/nested/nest_1.adb And the demo with the issue solved properly: https://github.com/Blunk-electronic/ada_training/blob/master/src/containers/demo/nested/nest_2.adb Still the question remains, why such a dangling cursor is not detected at runtime.