220 36725 <CALvx3hbdgOOP14o37Wdx5VpuQTS+M-+MP7GXGbkLeTViiUsHcA@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Richard Hodges <hodges.r@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Static analysis and the future of C++
Date: Sat, 20 Jan 2018 17:48:16 +0100
Lines: 785
Approved: news@gmane.org
Message-ID: <CALvx3hbdgOOP14o37Wdx5VpuQTS+M-+MP7GXGbkLeTViiUsHcA@mail.gmail.com>
References: <0087c1a4-0b36-40ca-8d43-5bfaf0af62ca@isocpp.org>
 <a395ffbf-fc53-4288-b1ca-f559e1703eac@isocpp.org> <88864914-82a8-4a8b-bda7-cffd38379edf@isocpp.org>
 <4fa792ec-1f51-4357-a65a-2ce3c10c60c0@isocpp.org> <CALvx3hYQHFXi5eRrcdCGEqWj-n4w4NKYDpRx4G_U16i+2VS5nQ@mail.gmail.com>
 <00d91d4c-4ee7-4dbd-a547-3dd844f5685d@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="94eb2c0b91f0b6b8d0056337f6de"
X-Trace: blaine.gmane.org 1516466792 6299 195.159.176.226 (20 Jan 2018 16:46:32 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 20 Jan 2018 16:46:32 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD4PBM7UWAHRBUPFRXJQKGQESZV247Y@isocpp.org Sat Jan 20 17:46:28 2018
Return-path: <std-proposals+bncBD4PBM7UWAHRBUPFRXJQKGQESZV247Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-io0-f198.google.com ([209.85.223.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBD4PBM7UWAHRBUPFRXJQKGQESZV247Y@isocpp.org>)
	id 1ecwHW-0000Vs-Mf
	for gclcip-std-proposals@m.gmane.org; Sat, 20 Jan 2018 17:46:15 +0100
Original-Received: by mail-io0-f198.google.com with SMTP id b184sf5189266iof.21
        for <gclcip-std-proposals@m.gmane.org>; Sat, 20 Jan 2018 08:48:19 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1516466898; cv=pass;
        d=google.com; s=arc-20160816;
        b=exIt3wLJAWzIICQX4xiFnvdbIharhHEdXn8r+GDX1EhnJywbWyx0tdZ0gIfGAmZl1C
         rDjnBLO09CwqhTkAne3EdHNe8/B/bSrSfTzrVpbMo7DFIXVkXsSL1UT4zjW7bJqpASb4
         6cV8wkLie/4vb+em9ZLrP4Bn8pOK0E3OKg5re0S/5YXyWqXH0k4KXDYpw+k+v6vpAFR/
         yrp9+WcUS4OPwwgiHreR9ZNcjqZhCu5+vAFQkZAdg1g1Hj6ZOrK/dPZxSGZtI884C2zP
         F4MJ7t0FK0dwsvdzoCP32Fvm/U4tAtrLex/kPoWLrmXLq7UXMU0UXb7xweuP0AO5T/+M
         nBJQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=MBeO7HKsDEpM8p6U6ADC5G1aePcN/RIiHlf3AigSWo8=;
        b=ZVLNtQJks7JClil0TT6zwVeWX2uGT1KJ1hBFN+QmKtJcU8PCMXGoqGznUSbyLuDUGm
         v6fjaC0ZUB7JSb+/4Ut1y67VCAXzGLmdv5N6yQWBfFqLLsculNEDqIa+GIj0gTXv8hwX
         OqheDBZRMYLlF2RNNplMXrUbrC342SWVWO8bQTUAh1KpsyXoJtH0boUo7i9NGkUIaM93
         rLXuh17qT8DnNiYRJd6NP6dppTtoB7Dg8tr4tcR5+g4dwglSWmzK2R5CJaamISTpqduX
         W7VDVfLqM1LGci4c5v3Ywah/TDy0zSW0Eq9DuQ69x/ZoOaJBB21dKeHYJG5J2A2aQXdY
         Jryw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q393fUVW;
       spf=pass (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=hodges.r@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=MBeO7HKsDEpM8p6U6ADC5G1aePcN/RIiHlf3AigSWo8=;
        b=snS7XL9tZDM3eK0NEEEyEp0glbCituqnG0ZQ32iy7FY5vRGc0YlJist6KIN4Dwi3uS
         8WCyPZcCbugHpwBqgC1uoH42BZREbiHDgeuTLUMbdvcIBj9tFb57I4sA/vJhUVXhos2S
         qVVUwk4wTnbfCXfbEjPueGPvVaHxSVihlKT8Xz+vdRHpkBLZAlRwnPZjpTBFY3dbZETA
         wVnXZwmYthsJAE+Uq9uPaOL5R90qdKRQzUOrMPPKITFvLvc5515EqBLKyHKH7USXqj6L
         v9XQgomP56DjXEh4vS03HkSC0WJhUwpkt0CgHHfSRc8E5BES3Ov4sAJf1rwpqZibZoj0
         7Wsg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=MBeO7HKsDEpM8p6U6ADC5G1aePcN/RIiHlf3AigSWo8=;
        b=XHMSgCQUsgCT58I2YdpRvkxq2pcesgDTeh7pNRwCXSLLNpOszjEp7CFgAXWl0WSNG3
         XnlBtngYNtJmN6V+fLU0r6HCwv3PjGJRKyL31hcypb4frlavbY7ejrDUzfh4L3T2xkZx
         iaGCTzq9FozuSswLoWlYz7dX7cbBu/J4un04VIbq/x/Y0X1A/SPvMPVQpRk5GKCD8USO
         4pg8kGwOI02ub70ufsR+5W76PXr3pquvI7ajPSMVfmrfGwVBhPbeukM7iRDGPDfPzmHY
         3XPW0RAbMZCYEqI8UFICmVNBkIBSm6MT3EYNpzIXF5dmr6UQurUVZWB/Wat/xKTi/39V
         AhcQ==
X-Gm-Message-State: AKwxyteyKQq7rUi3MV/kkniomj1cn2Z58fe+iGh/QS/LH8EchqBcA4tE
	r/G0AFuqGnAOjxEB43/lt9SdCA==
X-Google-Smtp-Source: AH8x227nCQFVb+sTbVHMnAvc9+vSQb3XHKlfCxP6MKqDeOp6fsyp906fljLS1vByJDpiOr/rUPFVSA==
X-Received: by 10.107.12.227 with SMTP id 96mr1770243iom.106.1516466898728;
        Sat, 20 Jan 2018 08:48:18 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.174.24 with SMTP id x24ls892112ioe.23.gmail; Sat, 20 Jan
 2018 08:48:17 -0800 (PST)
X-Received: by 10.36.39.138 with SMTP id g132mr2115856ita.89.1516466897494;
        Sat, 20 Jan 2018 08:48:17 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1516466897; cv=none;
        d=google.com; s=arc-20160816;
        b=PsDRHq+6WhDWZP1BrvoZVf0PwG55SCFVEjcM0TQV8LeLYAp/8DuYm5phz3SGPOC7pN
         PtsqcMaL0wS7ZA+Hayo2AmOPElkTkkL/cQl4snYLG5LW5CZy2yAG35DJKaOseiDLjXqM
         rHDNQ2JPxfK+gJ1wZiP4zWC1mBU3oyM++zheTXsOdInuti/IvLjUhBbl7wbzta6lZhyt
         Egvnq0k1PGkq/Cd1Jed8oE8jp7O+MOR1w4YcCAKFEGOOcXBdDK8mUvOD/3VKGzu27nju
         ubhtX9wcAaX4X6VqMjYU7OCtgivR1mw7Pkxu4Fb92pnqXmTP9lafmWdUgvjPP70hbkqs
         YA2g==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=mJYieJNEBEhE9rLtVwsSgBCzjHSaef8ZLqz7DPQdbBc=;
        b=IZ1X2cYx3+jfhutq6X08c2IiWzqK2a8EA3WdShKtp7G8i/zehGJDDNssiFYQ+b/DYK
         rCoxGHM7BlwxdTL5bBQiCQaiymFe9P8gouNcO3C3VC47g4m+yp0dGddyCPlKdHwIooYc
         dWOERPgRCH68eJcAsDERMECD3qn2Q4EQvJZNAtBk/t1AzU5YO//7RK0lPKArn0cwuq3K
         b9DNqC+1SHlxr8BfjS5YlDb1dD0aiHU1bdQrNajSYKh8Guz3ynvy7SxGYcPtSQ1MXNwF
         ExFGANOV1RMNIDD+rl9cnUIeM9U1xsGcQr8D/soQUuJRCRxWSN32Ojaie29+GXWKV01g
         KMVA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q393fUVW;
       spf=pass (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=hodges.r@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id 66sor1305130iow.283.2018.01.20.08.48.17
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Sat, 20 Jan 2018 08:48:17 -0800 (PST)
Received-SPF: pass (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 10.107.183.78 with SMTP id h75mr2337145iof.201.1516466897072;
 Sat, 20 Jan 2018 08:48:17 -0800 (PST)
Original-Received: by 10.2.164.138 with HTTP; Sat, 20 Jan 2018 08:48:16 -0800 (PST)
In-Reply-To: <00d91d4c-4ee7-4dbd-a547-3dd844f5685d@isocpp.org>
X-Original-Sender: hodges.r@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=Q393fUVW;       spf=pass
 (google.com: domain of hodges.r@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=hodges.r@gmail.com;       dmarc=pass (p=NONE
 sp=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:36725
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36725>

--94eb2c0b91f0b6b8d0056337f6de
Content-Type: text/plain; charset="UTF-8"

> In your example, the compiler should warn it can't predict the observer -
has no visibility over its lifetime and/or the observed destruction is
behind real time uncertainty.
> He might even suggest alternative like share/weak ptr, because *observe_ptr
was not the right tool in the first place!* The compiler will only reaffirm
that fact.

That would indeed be a useful feature.


On 20 January 2018 at 17:36, <mihailnajdenov@gmail.com> wrote:

>
>
> On Saturday, January 20, 2018 at 4:54:53 PM UTC+2, Richard Hodges wrote:
>>
>> > Copies of observer_ptr still monitor the same address, but with a
>> different scope - their dtor, release or reset.
>>
>> It would be nice if this were enough.
>>
>> consider
>>
>> auto& exec = some_async_executor();
>> auto up = std::make_unique<Foo>();
>>
>> auto p = observer_ptr(up.get());
>> exec.post([p] { something_with(*p); });    // A
>> exec.post([up = std::move(up)] { something_with(*up); }); // B
>> exec.post([p] { something_with(*p); });   // C
>>
>> Assume that B's lambda invocation may or may not complete before C's lambda
>> invocation.
>>
>> I can't see how this could be statically analysed. It's an undetectable
>> logic error, since as far as the compiler is concerned, it has no way of
>> knowing that C's p may outlive B's up.
>>
>> Note that at the point of the construction of each of the 3 lambdas, the
>> pointers captured are all valid (except in the crossing case where there is
>> a context switch after the post at B).
>>
>
>
> In any case this does heap allocation for the views (the lambdas, inside
> the exec class) and presumably threading after that. Both are impossible to
> track.
>
>
> For both however we have nice tools - shared and week ptr.
>
> Which is ironic - the complex code is more safe then the trivial one. Yes
> you could use the heavyweight tools for simple tasks, but that is not zero
> overhead any more.
>
> Static analysis is the tool to help us with the common, simple, yet
> (terribly) unsafe tasks, still keeping zero overhead.
>
>
> Having said that, there are scenarios where tracking will not give
> accurate prediction - the destruction might, for instance, depend upon some
> real time state.
> That is the reason, these cannot be errors, only warnings.
> The compiler should, however, be able to see all paths leading to
> destruction even the once behind real time check/uncertainty and warn that
> "it *might *dangle" or that "no one can be certain, even you!".
>
> In your example, the compiler should warn it can't predict the observer -
> has no visibility over its lifetime and/or the observed destruction is
> behind real time uncertainty.
> He might even suggest alternative like share/weak ptr, because *observe_ptr
> was not the right tool in the first place!* The compiler will only
> reaffirm that fact.
>
>
>
>>
>>
>>
>> On 20 January 2018 at 12:12, <mihailn...@gmail.com> wrote:
>>
>>>
>>>
>>> On Friday, January 19, 2018 at 10:19:40 PM UTC+2, Nicol Bolas wrote:
>>>>
>>>> On Friday, January 19, 2018 at 7:30:52 AM UTC-5, mihailn...@gmail.com
>>>> wrote:
>>>>>
>>>>> Can we "just" define special behavior of observer_ptr (in
>>>>> debug/analyze mode) and solve all cases of lifetime monitoring (under the
>>>>> said limitations) - from smart pointers to function_view?
>>>>>
>>>>
>>>> That's not "behavior" of the type. There is no actual code in
>>>> `observer_ptr` that does anything you're talking about. It's simply a
>>>> compiler or tool that sees you using this particular type and starts
>>>> looking at things because of it.
>>>>
>>>
>>> If the constructor and reset of observer_ptr are decorated with
>>> something like [[debug:observe_destruction]] the behavior of observer_ptr
>>> will be enforced by the compiler.
>>>
>>> The behavior, use and definition of observer_ptr are not changed.
>>>
>>>
>>>>
>>>> It should also be noted that this still doesn't handle perfect
>>>> forwarding. Not unless it is the caller of the function who wraps the
>>>> parameter in an `observer_ptr`.
>>>>
>>>
>>> class A_view
>>> {
>>>   A_view(const A* pa) : _p(pa) {}
>>>   A_view(const A& a) : _p(&a) {}
>>>   A_view(A&& a) : _p(&a) {}
>>>
>>>   observer_ptr<const A> _p;
>>> };
>>>
>>> observer_ptr will monitor addressof(*_p) for ~A() call. The scope of
>>> monitoring is ~observer_ptr() or release() call.
>>>
>>> Copies of observer_ptr still monitor the same address, but with a
>>> different scope - their dtor, release or reset.
>>>
>>>
>>> That is a major difference from lifetime extension - we can have
>>> many-to-one mapping without any semantic or implementation problems. Lifetime
>>> extension does not allow copies of a view/ref to extend with the lifetime
>>> of the object.
>>> We are also not limited to initialization only - the monitoring can
>>> (re)start at the call of reset() instead on constructor call only. Lifetime
>>> extension deals with initialization exclusively.
>>>
>>>
>>> How can perfect forwarding interfere in all this?
>>>
>>>
>>> template<typename T, typename ...Args>
>>> auto init(Args&&... arg)
>>> {
>>>   return T(std::forward<Args>(arg)...); //< observer_ptr starts
>>> monitoring &arg
>>> }
>>>
>>> int main()
>>> {
>>>   auto v = init<A_view>(A{}); //< both A_view and A allocated. A_view
>>> usable before the ';' when ~A is called
>>> }
>>>
>>> If copy elision does not kick-in nothing changes - copy is safe and
>>> defined, lifetime of A is the same.
>>>
>>> If we pass arguments and create A in init() instead ( return
>>> T(A(std::forward<Args>(arg)...)); ), then the observer_ptr is still
>>> created with a valid address,
>>> however, after we return will not be able to use A_view in any way,
>>> including before the ';'.
>>>
>>> If both there is no elision and A is created when initializing T inside
>>> init, then the returned view can be created from a dangling view.
>>> We could allow views from dangling views to be created, however no dtor
>>> will be monitored and all uses of the view will be illegal until
>>> destroyed/reset/release-ed.
>>> We could also issue a warning on coping from dangling view without
>>> problem.
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "ISO C++ Standard - Future Proposals" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to std-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> To view this discussion on the web visit https://groups.google.com/a/is
>>> ocpp.org/d/msgid/std-proposals/4fa792ec-1f51-4357-a65a-
>>> 2ce3c10c60c0%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4fa792ec-1f51-4357-a65a-2ce3c10c60c0%40isocpp.org?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/00d91d4c-4ee7-4dbd-
> a547-3dd844f5685d%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/00d91d4c-4ee7-4dbd-a547-3dd844f5685d%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hbdgOOP14o37Wdx5VpuQTS%2BM-%2BMP7GXGbkLeTViiUsHcA%40mail.gmail.com.

--94eb2c0b91f0b6b8d0056337f6de
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">&gt;=C2=A0<span style=3D"font-size:12.8px">In your example=
, the compiler should warn it can&#39;t predict the observer - has no visib=
ility over its lifetime and/or the observed destruction is behind real time=
 uncertainty.=C2=A0</span><div style=3D"font-size:12.8px">&gt; He might eve=
n suggest alternative like share/weak ptr, because=C2=A0<i>observe_ptr was =
not the right tool in the first place!</i>=C2=A0The compiler will only reaf=
firm that fact.=C2=A0</div><div><br></div><div>That would indeed be a usefu=
l feature.</div><div><br></div></div><div class=3D"gmail_extra"><br><div cl=
ass=3D"gmail_quote">On 20 January 2018 at 17:36,  <span dir=3D"ltr">&lt;<a =
href=3D"mailto:mihailnajdenov@gmail.com" target=3D"_blank">mihailnajdenov@g=
mail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><span class=3D""><br><br>On Saturday, January 20, 2018 at 4:54:53 =
PM UTC+2, Richard Hodges wrote:<blockquote class=3D"gmail_quote" style=3D"m=
argin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div=
 dir=3D"ltr">&gt;=C2=A0<span style=3D"font-size:13px">Copies of=C2=A0</span=
><span style=3D"font-size:13px;background-color:transparent;margin:0px;padd=
ing:0px;border:0px rgb(34,34,34)">observer_ptr still monitor the same addre=
ss, but with a different scope - their dtor, release or reset.</span><div><=
span style=3D"font-size:13px;background-color:transparent;margin:0px;paddin=
g:0px;border:0px rgb(34,34,34)"><br></span></div><div><span style=3D"font-s=
ize:13px;background-color:transparent;margin:0px;padding:0px;border:0px rgb=
(34,34,34)">It would be nice if this were enough.</span></div><div><span st=
yle=3D"font-size:13px;background-color:transparent;margin:0px;padding:0px;b=
order:0px rgb(34,34,34)"><br></span></div><div><span style=3D"font-size:13p=
x;background-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,=
34)">consider</span></div><div><span style=3D"font-size:13px;background-col=
or:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><br></span>=
</div><div><span style=3D"font-size:13px;background-color:transparent;margi=
n:0px;padding:0px;border:0px rgb(34,34,34)"><font face=3D"monospace, monosp=
ace">auto&amp; exec =3D some_async_executor();</font></span></div><div><spa=
n style=3D"font-size:13px;background-color:transparent;margin:0px;padding:0=
px;border:0px rgb(34,34,34)"><font face=3D"monospace, monospace">auto up =
=3D std::make_unique&lt;Foo&gt;();</font></span></div><div><span style=3D"f=
ont-size:13px;background-color:transparent;margin:0px;padding:0px;border:0p=
x rgb(34,34,34)"><font face=3D"monospace, monospace"><br></font></span></di=
v><div><span style=3D"font-size:13px;background-color:transparent;margin:0p=
x;padding:0px;border:0px rgb(34,34,34)"><font face=3D"monospace, monospace"=
>auto p =3D observer_ptr(up.get());</font></span></div><div><div><span styl=
e=3D"font-size:13px;background-color:transparent;margin:0px;padding:0px;bor=
der:0px rgb(34,34,34)"><font face=3D"monospace, monospace">exec.post([p] { =
something_with(*p); });=C2=A0 =C2=A0 // A</font></span></div></div><div><sp=
an style=3D"background-color:transparent;margin:0px;padding:0px;border:0px =
rgb(34,34,34)"><div style=3D"font-size:small"><span style=3D"font-size:13px=
;background-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,3=
4)"><font face=3D"monospace, monospace">exec.post([up =3D std::move(up)] { =
something_with(*up); }); // B</font></span></div></span><div><span style=3D=
"background-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,3=
4)"><span style=3D"background-color:transparent;margin:0px;padding:0px;bord=
er:0px rgb(34,34,34)"><div style=3D"font-size:small"><span style=3D"font-si=
ze:13px;background-color:transparent;margin:0px;padding:0px;border:0px rgb(=
34,34,34)"><font face=3D"monospace, monospace">exec.post([p] { something_wi=
th(*p); });=C2=A0 =C2=A0// C</font></span></div><div style=3D"font-size:sma=
ll"><span style=3D"font-size:13px;background-color:transparent;margin:0px;p=
adding:0px;border:0px rgb(34,34,34)"><br></span></div><div>Assume that B&#3=
9;s lambda invocation may or may not complete before C&#39;s=C2=A0<span sty=
le=3D"background-color:transparent">lambda invocation</span><span style=3D"=
background-color:transparent">.</span></div><div style=3D"font-size:small">=
<span style=3D"font-size:13px;background-color:transparent;margin:0px;paddi=
ng:0px;border:0px rgb(34,34,34)"><br></span></div><div style=3D"font-size:s=
mall"><span style=3D"font-size:13px;background-color:transparent;margin:0px=
;padding:0px;border:0px rgb(34,34,34)">I can&#39;t see how this could be st=
atically analysed. It&#39;s an undetectable logic error, since as far as th=
e compiler is concerned, it has no way of knowing that C&#39;s <font face=
=3D"monospace, monospace">p</font> may outlive B&#39;s <font face=3D"monosp=
ace, monospace">up</font>.</span></div><div style=3D"font-size:small"><span=
 style=3D"font-size:13px;background-color:transparent;margin:0px;padding:0p=
x;border:0px rgb(34,34,34)"><br></span></div></span></span><div style=3D"fo=
nt-size:13px"><span style=3D"background-color:transparent;margin:0px;paddin=
g:0px;border:0px rgb(34,34,34)"><span style=3D"background-color:transparent=
;margin:0px;padding:0px;border:0px rgb(34,34,34)"><span style=3D"font-size:=
13px;background-color:transparent;margin:0px;padding:0px;border:0px rgb(34,=
34,34)">Note that at the point of the construction of each of the 3 lambdas=
, the pointers captured are all valid (except in the crossing case where th=
ere is a context switch after the post at B).</span></span></span></div></d=
iv></div></div></blockquote><div><br></div><div><br></div></span><div>In an=
y case this does heap allocation for the views (the lambdas, inside the exe=
c class) and presumably threading after that. Both are impossible to track.=
 </div><div><br></div><div><br></div><div>For both however we have nice too=
ls - shared and week ptr.=C2=A0</div><div><br></div><div>Which is ironic - =
the complex code is more safe then the trivial one. Yes you could use the h=
eavyweight tools for simple tasks, but that is not zero overhead any more.=
=C2=A0</div><div><br></div><div>Static analysis is the tool to help us with=
 the common, simple, yet (terribly) unsafe tasks, still keeping zero overhe=
ad.</div><div><br></div><div><br></div><div>Having said that, there are sce=
narios where tracking will not give accurate prediction - the destruction m=
ight, for instance, depend upon some real time state.</div><div>That is the=
 reason, these cannot be errors, only warnings.</div><div>The compiler shou=
ld, however, be able to see all paths leading to destruction even the once =
behind real time check/uncertainty and warn that &quot;it <i>might </i>dang=
le&quot; or that &quot;no one can be certain, even you!&quot;.</div><div><b=
r></div><div>In your example, the compiler should warn it can&#39;t predict=
 the observer - has no visibility over its lifetime and/or the observed des=
truction is behind real time uncertainty.=C2=A0<b><i></i></b></div><div>He =
might even suggest alternative like share/weak ptr, because <i>observe_ptr =
was not the right tool in the first place!</i> The compiler will only reaff=
irm that fact.=C2=A0</div><div><br></div><div>=C2=A0</div><blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div><span style=3D"background-colo=
r:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><div><span s=
tyle=3D"background-color:transparent;margin:0px;padding:0px;border:0px rgb(=
34,34,34)"><div style=3D"font-size:13px"><span style=3D"font-size:13px;back=
ground-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,34)"><=
br></span></div><div style=3D"font-size:13px"><span style=3D"font-size:13px=
;background-color:transparent;margin:0px;padding:0px;border:0px rgb(34,34,3=
4)"><br></span></div></span></div></span></div></div><div><br><div class=3D=
"gmail_quote"><div><div class=3D"h5">On 20 January 2018 at 12:12,  <span di=
r=3D"ltr">&lt;<a rel=3D"nofollow">mihailn...@gmail.com</a>&gt;</span> wrote=
:<br></div></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class=3D"h5"><div=
 dir=3D"ltr"><span><br><br>On Friday, January 19, 2018 at 10:19:40 PM UTC+2=
, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;mar=
gin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr=
">On Friday, January 19, 2018 at 7:30:52 AM UTC-5, <a>mihailn...@gmail.com<=
/a> wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0=
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><fo=
nt face=3D"arial,sans-serif"><span style=3D"text-align:left;color:rgb(34,34=
,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-size:13=
px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:no=
ne;word-spacing:0px;display:inline!important;white-space:normal;float:none;=
background-color:transparent">Can we <span style=3D"display:inline!importan=
t;float:none;background-color:transparent;color:rgb(34,34,34);font-family:a=
rial,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-w=
eight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-i=
ndent:0px;text-transform:none;white-space:normal;word-spacing:0px">&quot;ju=
st&quot; </span>define special behavior of=C2=A0<span style=3D"background-c=
olor:transparent;border-bottom-color:rgb(34,34,34);border-bottom-style:none=
;border-bottom-width:0px;border-left-color:rgb(34,34,34);border-left-style:=
none;border-left-width:0px;border-right-color:rgb(34,34,34);border-right-st=
yle:none;border-right-width:0px;border-top-color:rgb(34,34,34);border-top-s=
tyle:none;border-top-width:0px;color:rgb(34,34,34);display:inline;float:non=
e;font-family:arial,sans-serif;font-size:13px;font-style:normal;font-varian=
t:normal;font-weight:400;letter-spacing:normal;margin-bottom:0px;margin-lef=
t:0px;margin-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;p=
adding-right:0px;padding-top:0px;text-align:left;text-decoration:none;text-=
indent:0px;text-transform:none;white-space:normal;word-spacing:0px">observe=
r_ptr (in debug/analyze mode) and solve all cases of lifetime monitoring (u=
nder the said limitations) - from smart pointers to function_view?</span></=
span></font></div></div></blockquote><div><br></div><div>That&#39;s not &qu=
ot;behavior&quot; of the type. There is no actual code in `observer_ptr` th=
at does anything you&#39;re talking about. It&#39;s simply a compiler or to=
ol that sees you using this particular type and starts looking at things be=
cause of it.</div></div></blockquote><div><br></div></span><div>If the cons=
tructor and reset of <span style=3D"display:inline!important;float:none;bac=
kground-color:transparent;color:rgb(34,34,34);font-family:&quot;Arial&quot;=
,&quot;Helvetica&quot;,sans-serif;font-size:13px;font-style:normal;font-var=
iant:normal;font-weight:400;letter-spacing:normal;text-align:left;text-deco=
ration:none;text-indent:0px;text-transform:none;white-space:normal;word-spa=
cing:0px">observer_ptr are decorated with something like<font face=3D"couri=
er new,monospace"> [[debug:observe_destruction]] </font>the=C2=A0<span styl=
e=3D"display:inline!important;float:none;background-color:transparent;color=
:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;Helvetica&quot;,sans-ser=
if;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;let=
ter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;tex=
t-transform:none;white-space:normal;word-spacing:0px">behavior of=C2=A0<spa=
n>observer_ptr will be enforced by the compiler. </span></span></span></div=
><div><span style=3D"display:inline!important;float:none;background-color:t=
ransparent;color:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;Helvetic=
a&quot;,sans-serif;font-size:13px;font-style:normal;font-variant:normal;fon=
t-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;tex=
t-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span=
 style=3D"display:inline!important;float:none;background-color:transparent;=
color:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot;Helvetica&quot;,san=
s-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:40=
0;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0p=
x;text-transform:none;white-space:normal;word-spacing:0px"><span><br></span=
></span></span></div><div><span style=3D"display:inline!important;float:non=
e;background-color:transparent;color:rgb(34,34,34);font-family:&quot;Arial&=
quot;,&quot;Helvetica&quot;,sans-serif;font-size:13px;font-style:normal;fon=
t-variant:normal;font-weight:400;letter-spacing:normal;text-align:left;text=
-decoration:none;text-indent:0px;text-transform:none;white-space:normal;wor=
d-spacing:0px"><span style=3D"display:inline!important;float:none;backgroun=
d-color:transparent;color:rgb(34,34,34);font-family:&quot;Arial&quot;,&quot=
;Helvetica&quot;,sans-serif;font-size:13px;font-style:normal;font-variant:n=
ormal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration=
:none;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0=
px"><span>The behavior, use and definition of observer_ptr are not changed.=
 =C2=A0</span></span></span></div><span><div>=C2=A0</div><blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div><br></div><div>It should also =
be noted that this still doesn&#39;t handle perfect forwarding. Not unless =
it is the caller of the function who wraps the parameter in an `observer_pt=
r`.</div></div></blockquote><div><br></div></span><div><font face=3D"courie=
r new,monospace">class A_view</font></div><div><font face=3D"courier new,mo=
nospace">{</font></div><div><font face=3D"courier new,monospace">=C2=A0 </f=
ont><font face=3D"courier new,monospace"><span style=3D"text-align:left;col=
or:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;=
font-size:13px;font-style:normal;font-variant:normal;font-weight:400;text-d=
ecoration:none;word-spacing:0px;display:inline!important;white-space:normal=
;float:none;background-color:transparent">A_view(const A* pa) : _p(pa) {}</=
span></font></div><div><font face=3D"courier new,monospace">=C2=A0 <span st=
yle=3D"text-align:left;color:rgb(34,34,34);text-transform:none;text-indent:=
0px;letter-spacing:normal;font-size:13px;font-style:normal;font-variant:nor=
mal;font-weight:400;text-decoration:none;word-spacing:0px;display:inline!im=
portant;white-space:normal;float:none;background-color:transparent"><span>A=
_view(const A&amp; a) : _p(&amp;a) {}</span></span></font></div><div><font =
face=3D"courier new,monospace">=C2=A0 <span style=3D"text-align:left;color:=
rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;fon=
t-size:13px;font-variant:normal;word-spacing:0px;display:inline!important;w=
hite-space:normal;float:none;background-color:transparent"><span style=3D"m=
argin:0px;padding:0px;border:0px rgb(34,34,34);text-align:left;color:rgb(34=
,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-size=
:13px;font-variant:normal;word-spacing:0px;display:inline;white-space:norma=
l;float:none;background-color:transparent"><span>A_view(A&amp;&amp; a) : _p=
(&amp;a) {}</span></span></span></font></div><div><span style=3D"text-align=
:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacin=
g:normal;font-size:13px;font-variant:normal;word-spacing:0px;display:inline=
!important;white-space:normal;float:none;background-color:transparent"><spa=
n style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);text-align:left;=
color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:norm=
al;font-size:13px;font-variant:normal;word-spacing:0px;display:inline;white=
-space:normal;float:none;background-color:transparent"><span><font face=3D"=
courier new,monospace"><br></font></span></span></span></div><div><font fac=
e=3D"courier new,monospace">=C2=A0 <span style=3D"text-align:left;color:rgb=
(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-s=
ize:13px;font-variant:normal;word-spacing:0px;display:inline!important;whit=
e-space:normal;float:none;background-color:transparent"><span style=3D"marg=
in:0px;padding:0px;border:0px rgb(34,34,34);text-align:left;color:rgb(34,34=
,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-size:13=
px;font-variant:normal;word-spacing:0px;display:inline;white-space:normal;f=
loat:none;background-color:transparent"><span>observer_ptr&lt;const A&gt; _=
p;</span><b></b></span></span></font></div><div><font face=3D"courier new,m=
onospace">};=C2=A0</font></div><div><font face=3D"courier new"><br></font><=
/div><div><font face=3D"arial,sans-serif">observer_ptr will monitor address=
of(*_p) for ~A() call. The scope of monitoring is ~<span style=3D"text-alig=
n:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spaci=
ng:normal;font-size:13px;font-style:normal;font-variant:normal;font-weight:=
400;text-decoration:none;word-spacing:0px;display:inline!important;white-sp=
ace:normal;float:none;background-color:transparent">observer_ptr() or relea=
se() call.</span></font></div><div><font face=3D"arial,sans-serif"><span st=
yle=3D"text-align:left;color:rgb(34,34,34);text-transform:none;text-indent:=
0px;letter-spacing:normal;font-size:13px;font-style:normal;font-variant:nor=
mal;font-weight:400;text-decoration:none;word-spacing:0px;display:inline!im=
portant;white-space:normal;float:none;background-color:transparent"><br></s=
pan></font></div><div><font face=3D"arial,sans-serif"><span style=3D"text-a=
lign:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-sp=
acing:normal;font-size:13px;font-style:normal;font-variant:normal;font-weig=
ht:400;text-decoration:none;word-spacing:0px;display:inline!important;white=
-space:normal;float:none;background-color:transparent">Copies of=C2=A0<span=
 style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);text-align:left;c=
olor:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:norma=
l;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;text=
-decoration:none;word-spacing:0px;display:inline;white-space:normal;float:n=
one;background-color:transparent"><span style=3D"background-color:transpare=
nt;border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom=
-width:0px;border-left-color:rgb(34,34,34);border-left-style:none;border-le=
ft-width:0px;border-right-color:rgb(34,34,34);border-right-style:none;borde=
r-right-width:0px;border-top-color:rgb(34,34,34);border-top-style:none;bord=
er-top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13=
px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:nor=
mal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;paddi=
ng-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-align=
:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:=
normal;word-spacing:0px"><span style=3D"background-color:transparent;border=
-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-width:0p=
x;border-left-color:rgb(34,34,34);border-left-style:none;border-left-width:=
0px;border-right-color:rgb(34,34,34);border-right-style:none;border-right-w=
idth:0px;border-top-color:rgb(34,34,34);border-top-style:none;border-top-wi=
dth:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13px;font-s=
tyle:normal;font-variant:normal;font-weight:400;letter-spacing:normal;margi=
n-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom=
:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-align:left;tex=
t-decoration:none;text-indent:0px;text-transform:none;white-space:normal;wo=
rd-spacing:0px"><font face=3D"arial,sans-serif">observer_ptr still monitor =
the same address, but with a different scope - their dtor, release or reset=
..</font></span></span></span></span></font><font face=3D"arial,sans-serif">=
<span style=3D"text-align:left;color:rgb(34,34,34);text-transform:none;text=
-indent:0px;letter-spacing:normal;font-size:13px;font-style:normal;font-var=
iant:normal;font-weight:400;text-decoration:none;word-spacing:0px;display:i=
nline!important;white-space:normal;float:none;background-color:transparent"=
><span style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);text-align:=
left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing=
:normal;font-size:13px;font-style:normal;font-variant:normal;font-weight:40=
0;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;f=
loat:none;background-color:transparent"><span style=3D"background-color:tra=
nsparent;border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-=
bottom-width:0px;border-left-color:rgb(34,34,34);border-left-style:none;bor=
der-left-width:0px;border-right-color:rgb(34,34,34);border-right-style:none=
;border-right-width:0px;border-top-color:rgb(34,34,34);border-top-style:non=
e;border-top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-s=
ize:13px;font-style:normal;font-variant:normal;font-weight:400;letter-spaci=
ng:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px=
;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text=
-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-=
space:normal;word-spacing:0px"><span style=3D"background-color:transparent;=
border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bottom-wi=
dth:0px;border-left-color:rgb(34,34,34);border-left-style:none;border-left-=
width:0px;border-right-color:rgb(34,34,34);border-right-style:none;border-r=
ight-width:0px;border-top-color:rgb(34,34,34);border-top-style:none;border-=
top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-size:13px;=
font-style:normal;font-variant:normal;font-weight:400;letter-spacing:normal=
;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-=
bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-align:le=
ft;text-decoration:none;text-indent:0px;text-transform:none;white-space:nor=
mal;word-spacing:0px"></span></span></span></span></font></div><div><font f=
ace=3D"arial,sans-serif"><span style=3D"text-align:left;color:rgb(34,34,34)=
;text-transform:none;text-indent:0px;letter-spacing:normal;font-size:13px;f=
ont-style:normal;font-variant:normal;font-weight:400;text-decoration:none;w=
ord-spacing:0px;display:inline!important;white-space:normal;float:none;back=
ground-color:transparent"><span style=3D"margin:0px;padding:0px;border:0px =
rgb(34,34,34);text-align:left;color:rgb(34,34,34);text-transform:none;text-=
indent:0px;letter-spacing:normal;font-size:13px;font-style:normal;font-vari=
ant:normal;font-weight:400;text-decoration:none;word-spacing:0px;display:in=
line;white-space:normal;float:none;background-color:transparent"><span styl=
e=3D"background-color:transparent;border-bottom-color:rgb(34,34,34);border-=
bottom-style:none;border-bottom-width:0px;border-left-color:rgb(34,34,34);b=
order-left-style:none;border-left-width:0px;border-right-color:rgb(34,34,34=
);border-right-style:none;border-right-width:0px;border-top-color:rgb(34,34=
,34);border-top-style:none;border-top-width:0px;color:rgb(34,34,34);display=
:inline;float:none;font-size:13px;font-style:normal;font-variant:normal;fon=
t-weight:400;letter-spacing:normal;margin-bottom:0px;margin-left:0px;margin=
-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-right=
:0px;padding-top:0px;text-align:left;text-decoration:none;text-indent:0px;t=
ext-transform:none;white-space:normal;word-spacing:0px"><span style=3D"back=
ground-color:transparent;border-bottom-color:rgb(34,34,34);border-bottom-st=
yle:none;border-bottom-width:0px;border-left-color:rgb(34,34,34);border-lef=
t-style:none;border-left-width:0px;border-right-color:rgb(34,34,34);border-=
right-style:none;border-right-width:0px;border-top-color:rgb(34,34,34);bord=
er-top-style:none;border-top-width:0px;color:rgb(34,34,34);display:inline;f=
loat:none;font-size:13px;font-style:normal;font-variant:normal;font-weight:=
400;letter-spacing:normal;margin-bottom:0px;margin-left:0px;margin-right:0p=
x;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;padd=
ing-top:0px;text-align:left;text-decoration:none;text-indent:0px;text-trans=
form:none;white-space:normal;word-spacing:0px"><br></span></span></span></s=
pan></font></div><font face=3D"arial,sans-serif"><span style=3D"text-align:=
left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing=
:normal;font-size:13px;font-style:normal;font-variant:normal;font-weight:40=
0;text-decoration:none;word-spacing:0px;display:inline!important;white-spac=
e:normal;float:none;background-color:transparent"><span style=3D"margin:0px=
;padding:0px;border:0px rgb(34,34,34);text-align:left;color:rgb(34,34,34);t=
ext-transform:none;text-indent:0px;letter-spacing:normal;font-size:13px;fon=
t-style:normal;font-variant:normal;font-weight:400;text-decoration:none;wor=
d-spacing:0px;display:inline;white-space:normal;float:none;background-color=
:transparent"><span style=3D"background-color:transparent;border-bottom-col=
or:rgb(34,34,34);border-bottom-style:none;border-bottom-width:0px;border-le=
ft-color:rgb(34,34,34);border-left-style:none;border-left-width:0px;border-=
right-color:rgb(34,34,34);border-right-style:none;border-right-width:0px;bo=
rder-top-color:rgb(34,34,34);border-top-style:none;border-top-width:0px;col=
or:rgb(34,34,34);display:inline;float:none;font-size:13px;font-style:normal=
;font-variant:normal;font-weight:400;letter-spacing:normal;margin-bottom:0p=
x;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:0px;paddin=
g-left:0px;padding-right:0px;padding-top:0px;text-align:left;text-decoratio=
n:none;text-indent:0px;text-transform:none;white-space:normal;word-spacing:=
0px"><span style=3D"background-color:transparent;border-bottom-color:rgb(34=
,34,34);border-bottom-style:none;border-bottom-width:0px;border-left-color:=
rgb(34,34,34);border-left-style:none;border-left-width:0px;border-right-col=
or:rgb(34,34,34);border-right-style:none;border-right-width:0px;border-top-=
color:rgb(34,34,34);border-top-style:none;border-top-width:0px;color:rgb(34=
,34,34);display:inline;float:none;font-size:13px;font-style:normal;font-var=
iant:normal;font-weight:400;letter-spacing:normal;margin-bottom:0px;margin-=
left:0px;margin-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0p=
x;padding-right:0px;padding-top:0px;text-align:left;text-decoration:none;te=
xt-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div=
><br></div></span></span></span></span></font><div><font face=3D"arial,sans=
-serif"><span style=3D"text-align:left;color:rgb(34,34,34);text-transform:n=
one;text-indent:0px;letter-spacing:normal;font-size:13px;font-style:normal;=
font-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;d=
isplay:inline!important;white-space:normal;float:none;background-color:tran=
sparent"><span style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);tex=
t-align:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter=
-spacing:normal;font-size:13px;font-style:normal;font-variant:normal;font-w=
eight:400;text-decoration:none;word-spacing:0px;display:inline;white-space:=
normal;float:none;background-color:transparent"><span style=3D"background-c=
olor:transparent;border-bottom-color:rgb(34,34,34);border-bottom-style:none=
;border-bottom-width:0px;border-left-color:rgb(34,34,34);border-left-style:=
none;border-left-width:0px;border-right-color:rgb(34,34,34);border-right-st=
yle:none;border-right-width:0px;border-top-color:rgb(34,34,34);border-top-s=
tyle:none;border-top-width:0px;color:rgb(34,34,34);display:inline;float:non=
e;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;lett=
er-spacing:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin=
-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:=
0px;text-align:left;text-decoration:none;text-indent:0px;text-transform:non=
e;white-space:normal;word-spacing:0px"><span style=3D"background-color:tran=
sparent;border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-b=
ottom-width:0px;border-left-color:rgb(34,34,34);border-left-style:none;bord=
er-left-width:0px;border-right-color:rgb(34,34,34);border-right-style:none;=
border-right-width:0px;border-top-color:rgb(34,34,34);border-top-style:none=
;border-top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-si=
ze:13px;font-style:normal;font-variant:normal;font-weight:400;letter-spacin=
g:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;=
padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-=
align:left;text-decoration:none;text-indent:0px;text-transform:none;white-s=
pace:normal;word-spacing:0px">That is a major difference from lifetime exte=
nsion - we can have many-to-one mapping without any semantic or implementat=
ion problems.=C2=A0<span style=3D"display:inline!important;float:none;backg=
round-color:transparent;color:rgb(34,34,34);font-family:arial,sans-serif;fo=
nt-size:13px;font-style:normal;font-variant:normal;font-weight:400;letter-s=
pacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-tra=
nsform:none;white-space:normal;word-spacing:0px">Lifetime extension does no=
t allow copies of a view/ref to extend with the lifetime of the object.</sp=
an></span></span></span></span></font></div><div><font face=3D"arial,sans-s=
erif"><span style=3D"text-align:left;color:rgb(34,34,34);text-transform:non=
e;text-indent:0px;letter-spacing:normal;font-size:13px;font-style:normal;fo=
nt-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;dis=
play:inline!important;white-space:normal;float:none;background-color:transp=
arent"><span style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);text-=
align:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-s=
pacing:normal;font-size:13px;font-style:normal;font-variant:normal;font-wei=
ght:400;text-decoration:none;word-spacing:0px;display:inline;white-space:no=
rmal;float:none;background-color:transparent"><span style=3D"background-col=
or:transparent;border-bottom-color:rgb(34,34,34);border-bottom-style:none;b=
order-bottom-width:0px;border-left-color:rgb(34,34,34);border-left-style:no=
ne;border-left-width:0px;border-right-color:rgb(34,34,34);border-right-styl=
e:none;border-right-width:0px;border-top-color:rgb(34,34,34);border-top-sty=
le:none;border-top-width:0px;color:rgb(34,34,34);display:inline;float:none;=
font-size:13px;font-style:normal;font-variant:normal;font-weight:400;letter=
-spacing:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-t=
op:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0p=
x;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;=
white-space:normal;word-spacing:0px"><span style=3D"background-color:transp=
arent;border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bot=
tom-width:0px;border-left-color:rgb(34,34,34);border-left-style:none;border=
-left-width:0px;border-right-color:rgb(34,34,34);border-right-style:none;bo=
rder-right-width:0px;border-top-color:rgb(34,34,34);border-top-style:none;b=
order-top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-size=
:13px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:=
normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;pa=
dding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-al=
ign:left;text-decoration:none;text-indent:0px;text-transform:none;white-spa=
ce:normal;word-spacing:0px">We are also not limited to initialization only =
- the monitoring can (re)start at the call of reset() instead on constructo=
r call only. Lifetime extension deals with initialization exclusively.=C2=
=A0</span></span></span></span></font></div><div><font face=3D"arial,sans-s=
erif"><span style=3D"text-align:left;color:rgb(34,34,34);text-transform:non=
e;text-indent:0px;letter-spacing:normal;font-size:13px;font-style:normal;fo=
nt-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;dis=
play:inline!important;white-space:normal;float:none;background-color:transp=
arent"><span style=3D"margin:0px;padding:0px;border:0px rgb(34,34,34);text-=
align:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-s=
pacing:normal;font-size:13px;font-style:normal;font-variant:normal;font-wei=
ght:400;text-decoration:none;word-spacing:0px;display:inline;white-space:no=
rmal;float:none;background-color:transparent"><span style=3D"background-col=
or:transparent;border-bottom-color:rgb(34,34,34);border-bottom-style:none;b=
order-bottom-width:0px;border-left-color:rgb(34,34,34);border-left-style:no=
ne;border-left-width:0px;border-right-color:rgb(34,34,34);border-right-styl=
e:none;border-right-width:0px;border-top-color:rgb(34,34,34);border-top-sty=
le:none;border-top-width:0px;color:rgb(34,34,34);display:inline;float:none;=
font-size:13px;font-style:normal;font-variant:normal;font-weight:400;letter=
-spacing:normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-t=
op:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0p=
x;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;=
white-space:normal;word-spacing:0px"><span style=3D"background-color:transp=
arent;border-bottom-color:rgb(34,34,34);border-bottom-style:none;border-bot=
tom-width:0px;border-left-color:rgb(34,34,34);border-left-style:none;border=
-left-width:0px;border-right-color:rgb(34,34,34);border-right-style:none;bo=
rder-right-width:0px;border-top-color:rgb(34,34,34);border-top-style:none;b=
order-top-width:0px;color:rgb(34,34,34);display:inline;float:none;font-size=
:13px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:=
normal;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;pa=
dding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;text-al=
ign:left;text-decoration:none;text-indent:0px;text-transform:none;white-spa=
ce:normal;word-spacing:0px"><br></span></span></span></span></font></div><d=
iv><font face=3D"arial,sans-serif"><span style=3D"text-align:left;color:rgb=
(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-s=
ize:13px;font-style:normal;font-variant:normal;font-weight:400;text-decorat=
ion:none;word-spacing:0px;display:inline!important;white-space:normal;float=
:none;background-color:transparent"><span style=3D"margin:0px;padding:0px;b=
order:0px rgb(34,34,34);text-align:left;color:rgb(34,34,34);text-transform:=
none;text-indent:0px;letter-spacing:normal;font-size:13px;font-style:normal=
;font-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;=
display:inline;white-space:normal;float:none;background-color:transparent">=
<span style=3D"background-color:transparent;border-bottom-color:rgb(34,34,3=
4);border-bottom-style:none;border-bottom-width:0px;border-left-color:rgb(3=
4,34,34);border-left-style:none;border-left-width:0px;border-right-color:rg=
b(34,34,34);border-right-style:none;border-right-width:0px;border-top-color=
:rgb(34,34,34);border-top-style:none;border-top-width:0px;color:rgb(34,34,3=
4);display:inline;float:none;font-size:13px;font-style:normal;font-variant:=
normal;font-weight:400;letter-spacing:normal;margin-bottom:0px;margin-left:=
0px;margin-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;pad=
ding-right:0px;padding-top:0px;text-align:left;text-decoration:none;text-in=
dent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span sty=
le=3D"background-color:transparent;border-bottom-color:rgb(34,34,34);border=
-bottom-style:none;border-bottom-width:0px;border-left-color:rgb(34,34,34);=
border-left-style:none;border-left-width:0px;border-right-color:rgb(34,34,3=
4);border-right-style:none;border-right-width:0px;border-top-color:rgb(34,3=
4,34);border-top-style:none;border-top-width:0px;color:rgb(34,34,34);displa=
y:inline;float:none;font-size:13px;font-style:normal;font-variant:normal;fo=
nt-weight:400;letter-spacing:normal;margin-bottom:0px;margin-left:0px;margi=
n-right:0px;margin-top:0px;padding-bottom:0px;padding-left:0px;padding-righ=
t:0px;padding-top:0px;text-align:left;text-decoration:none;text-indent:0px;=
text-transform:none;white-space:normal;word-spacing:0px"><br></span></span>=
</span></span></font></div><div>How can perfect forwarding interfere in all=
 this?=C2=A0</div><div><br></div><div><br></div><div><font face=3D"courier =
new,monospace"><span>template&lt;typename T, typename ...Args&gt;<br></span=
>auto init(Args&amp;&amp;... arg)<br>{<br>=C2=A0 return T(std::forward&lt;A=
rgs&gt;(arg)...); //&lt; observer_ptr starts monitoring &amp;arg<br>}<br><b=
r>int main()<br>{ <br>=C2=A0 auto v =3D init&lt;A_view&gt;(A{}); //&lt; bot=
h A_view and A allocated. A_view usable before the &#39;;&#39; when ~A is c=
alled<br>}</font></div><div><font face=3D"courier new"><br></font></div><di=
v>If copy elision does not kick-in nothing changes - copy is safe and defin=
ed, lifetime of A is the same.</div><div><br></div><div>If we pass argument=
s and create A in init() instead ( <font face=3D"courier new,monospace">ret=
urn</font>=C2=A0 <span style=3D"display:inline!important;float:none;backgro=
und-color:transparent;color:rgb(34,34,34);font-family:courier new,monospace=
;font-size:13px;font-style:normal;font-variant:normal;font-weight:400;lette=
r-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-=
transform:none;white-space:normal;word-spacing:0px">T(A(std::forward&lt;Arg=
s&gt;(arg)...<wbr>)); </span>), then the <font face=3D"courier new,monospac=
e">observer_ptr </font>is still created with a valid address, </div><div>ho=
wever, after we return will not be able to use<font face=3D"courier new,mon=
ospace"> A_view</font> in any way, including before the <font face=3D"couri=
er new,monospace">&#39;;&#39;.=C2=A0</font></div><div><b></b><i></i><u></u>=
<sub></sub><sup></sup><strike></strike><font face=3D"courier new,monospace"=
><br></font></div><div>If both there is no elision and A is created when in=
itializing T inside init, then the returned view can be created from a dang=
ling view.=C2=A0</div><div>We could allow views from dangling views to be c=
reated, however=C2=A0<span style=3D"display:inline!important;float:none;bac=
kground-color:transparent;color:rgb(34,34,34);font-family:&quot;Arial&quot;=
,&quot;Helvetica&quot;,sans-serif;font-size:13px;font-style:normal;font-var=
iant:normal;font-weight:400;letter-spacing:normal;text-align:left;text-deco=
ration:none;text-indent:0px;text-transform:none;white-space:normal;word-spa=
cing:0px">no dtor will be monitored and</span> all uses of the view will be=
 illegal until destroyed/reset/release-ed. </div><div>We could also issue a=
 warning on coping from dangling view without problem.</div><div><br></div>=
<div><br></div><div><br></div><div><font face=3D"arial,sans-serif"><b><i><b=
r></i></b></font></div><div>=C2=A0</div></div></div></div><span><div><div c=
lass=3D"h5">

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br></div></div>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</a>.<br></span><span class=3D"">
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/4fa792ec-1f51-4357-a65a-2ce3c10c60c0%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-pr=
oposals<wbr>/4fa792ec-1f51-4357-a65a-<wbr>2ce3c10c60c0%40isocpp.org</a>.<br=
>
</span></blockquote></div><br></div>
</blockquote></div><span class=3D"">

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/00d91d4c-4ee7-4dbd-a547-3dd844f5685d%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/00d9=
1d4c-4ee7-4dbd-<wbr>a547-3dd844f5685d%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3hbdgOOP14o37Wdx5VpuQTS%2BM-%2BM=
P7GXGbkLeTViiUsHcA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hbdgOOP=
14o37Wdx5VpuQTS%2BM-%2BMP7GXGbkLeTViiUsHcA%40mail.gmail.com</a>.<br />

--94eb2c0b91f0b6b8d0056337f6de--

.
