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,T_SCC_BODY_TEXT_LINE, XPRIO autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Adjust primitive not called on defaulted nonlimited controlled parameter, bug or feature ? Date: Wed, 17 Aug 2022 20:23:18 -0500 Organization: A noiseless patient Spider Message-ID: References: Injection-Date: Thu, 18 Aug 2022 01:23:20 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="2622ec0c9258f639e76de0fc1eae5c69"; logging-data="709614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/crHkvEhveZGYeAuTsBwCRXm4fdxkB1GQ=" Cancel-Lock: sha1:knEs6RlfZuyQvvgcJurBwlm1nLw= X-Priority: 3 X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 X-RFC2646: Format=Flowed; Response X-MSMail-Priority: Normal Xref: reader01.eternal-september.org comp.lang.ada:64205 List-Id: "Jeffrey R.Carter" wrote in message news:tdk03o$kljt$1@dont-email.me... > On 2022-08-17 22:11, David SAUVAGE wrote: >> In the code extract below [2] Adjust primitive is not called on defaulted >> nonlimited controlled parameter Set. >> A reproducer is available on gitlab [1] >> >> Seems like a bug, any feedbacks ? > > Adjust is called on assignment. Your code does no assignments. Right. A default parameter that is an object (as in this case) is simply passed to the subprogram, so there is no assignment when that happens, and thus no Adjust. If the default had been an aggregate or some more complex expression, then there would have been a new, temporary object. But new objects can be built-in-place, and if so, there is no assignment and no adjust (of the whole object, individual components are assigned). Build-in-place is required in some contexts, and since compilers have to implement it for those contexts, and it is cheaper in most contexts, it is likely to be used on almost all new objects (especially temporaries). It is tricky to determine precisely when non-limited controlled objects are Adjusted; the main rule of thumb is that any object that is Initialized or Adjusted will be Finalized, but one should not count on any particular number or order of Adjusts or Initializes. Anyway, the point is that one should never expect an Adjust to be associated with parameter passing; it could be in a few cases, but even then it could be omitted with different compiler settings (or a different compiler). Randy.