help / color / mirror / Atom feed
From: "Randy Brukardt" <>
Subject: Re: Adjust primitive not called on defaulted nonlimited controlled parameter, bug or feature ?
Date: Wed, 17 Aug 2022 20:23:18 -0500	[thread overview]
Message-ID: <tdk4a8$lkve$> (raw)
In-Reply-To: tdk03o$kljt$

"Jeffrey R.Carter" <> wrote in message 
> 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).


  reply	other threads:[~2022-08-18  1:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 20:11 Adjust primitive not called on defaulted nonlimited controlled parameter, bug or feature ? David SAUVAGE
2022-08-17 22:49 ` Jere
2022-08-18  0:11 ` Jeffrey R.Carter
2022-08-18  1:23   ` Randy Brukardt [this message]
2022-08-18  4:04     ` David SAUVAGE
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox