220 36641 <c0383e6d-1422-403a-b1a7-43769f6be4f7@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: mihailnajdenov@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Static analysis and the future of C++
Date: Mon, 15 Jan 2018 12:07:55 -0800 (PST)
Lines: 438
Approved: news@gmane.org
Message-ID: <c0383e6d-1422-403a-b1a7-43769f6be4f7@isocpp.org>
References: <0087c1a4-0b36-40ca-8d43-5bfaf0af62ca@isocpp.org>
 <4270ffec-ccc7-4abd-836d-213db296be84@isocpp.org>
 <08cecc11-e902-4542-a827-53dc45a125d5@isocpp.org>
 <4e25f92e-bd17-42e4-9a33-68916ae380d6@isocpp.org>
 <c568fb1e-3e63-4471-9b4a-7d1e6313c4df@isocpp.org>
 <a4ce1aca-9445-4557-b2d9-478e027bf0a0@isocpp.org>
 <9ec7a895-af7b-43d3-b47a-b7c95ed8660b@isocpp.org>
 <dc689be1-8ab4-4c06-86d9-4d9d9cc313b4@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2822_1777080784.1516046875619"
X-Trace: blaine.gmane.org 1516046759 5960 195.159.176.226 (15 Jan 2018 20:05:59 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 15 Jan 2018 20:05:59 +0000 (UTC)
Cc: mihailnajdenov@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCUJ3A7GRAPRBHEU6TJAKGQE2GJHCRY@isocpp.org Mon Jan 15 21:05:55 2018
Return-path: <std-proposals+bncBCUJ3A7GRAPRBHEU6TJAKGQE2GJHCRY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f70.google.com ([209.85.213.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCUJ3A7GRAPRBHEU6TJAKGQE2GJHCRY@isocpp.org>)
	id 1ebB10-0001Bi-C7
	for gclcip-std-proposals@m.gmane.org; Mon, 15 Jan 2018 21:05:54 +0100
Original-Received: by mail-vk0-f70.google.com with SMTP id o70sf7932220vke.0
        for <gclcip-std-proposals@m.gmane.org>; Mon, 15 Jan 2018 12:07:58 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=+0uWhznaFCObt3+XjxO4Ulkl8hfdN8zG292VMz5mu7Y=;
        b=i8GkZuxR4/x44CKhHSRGEKp3seDfB0b57pAbfSyk1EKGWPWC5i+xFBYpJXT227xZxr
         vuzRFEGoRKFHwHBn5C3rJPI5eH3liYfCfOjEFSH7UId6WP4Cw6WPZQN7OwtVHZOzlm8t
         uIpuKCyf0IscFnSpYQUNh9LUJ5H71sDD4/uXeuUeWijoEAuN3psABIkLo8ONjj4IJo7+
         nFiyM7D6cLSJTJe9cfn5tJY4lLqurISi2nwhPU7FaP1ZUQaMjnQkgZCWvgHoht9V7vDn
         EhZqKxf7bqAjQxcyugTKLxyCOIME+0h0kadNzZKs+B4aDaNd/ndXd6zl8XsJO50DlX2M
         jKrQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=+0uWhznaFCObt3+XjxO4Ulkl8hfdN8zG292VMz5mu7Y=;
        b=pDXt4LSRt3GWb1V6WqdNStQmhZSmJSLUBVjMrULnqaQzCALnKl/82+gleECY0klHng
         Fcg9gy0gOTo935VgPuzhzIRXYG6czPnYxRSXRuRYY1ZXhJb16RYv3OXLUIcP1YsCnJqK
         sZRhCrZYfYx8SlD8bxbonP4elAubRo4fKRRNzBJNJXUEGUP+uxsLYwTipLZfq2QkZPIt
         qXmapSY4eND3q9O/+F3a9aYuyKGexe7C9VE+K7dRVVjsWUT8suEgyt9WJCsi0uzv1hz9
         6iHrdMeA8f58hliNv+dKoXx7RzyEJMDWekU3q5Oo/mwMlxzQmZcjYiGjvUR1wHnt9Ohq
         106g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=+0uWhznaFCObt3+XjxO4Ulkl8hfdN8zG292VMz5mu7Y=;
        b=s/1ZE7pcZI0R9YzylYvkVuHZQT5RrUC4G+ll7gAU12piVsE7x+nTTnBty7JPt47eaZ
         NnutUMUIbGElKvZ99TaAOXK3rnk5kZoKTjX2tKxbjj2uijn8OCYp8F7IUUZEQrEOngMV
         pIhuHDwS328Xf7Fzm5V3/F3M5tzevcHKB2vvBhblTB8IhAWH1f3ORCqPO01pJ7FACWHs
         jHXrXB6RSnUdOpVYRE2hRhAcHSnAY9LEmih64Pwn2jjAxeJvk18Vi4MQCbe2D7Ffa+lE
         m/ATLAWWway0MxlI+GhsQ9DIuXzIW38rfqcEGXZNdgklbdUpKtLi6JAP+MJDFa5Vp8Nm
         Mzuw==
X-Gm-Message-State: AKwxytfifS/PRt/59GD4LHNcWFUVBQ+IHT8dOIiABHp8RbmIMiUquYWK
	lz1meCMUFXDG5E9m8nVIKZIT3g==
X-Google-Smtp-Source: ACJfBotDg+QZJDTZz8HesMBiBiHvcSvdYPoK7TzSMSaBJ5FzCHfC2DY9X6KCQU6moUGsmVLKtmFYvA==
X-Received: by 10.31.158.86 with SMTP id h83mr16492086vke.17.1516046878022;
        Mon, 15 Jan 2018 12:07:58 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.160.79 with SMTP id j76ls417043vke.17.gmail; Mon, 15 Jan
 2018 12:07:56 -0800 (PST)
X-Received: by 10.31.161.69 with SMTP id k66mr3871762vke.10.1516046876116;
        Mon, 15 Jan 2018 12:07:56 -0800 (PST)
In-Reply-To: <dc689be1-8ab4-4c06-86d9-4d9d9cc313b4@isocpp.org>
X-Original-Sender: MihailNajdenov@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:36641
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36641>

------=_Part_2822_1777080784.1516046875619
Content-Type: multipart/alternative; 
	boundary="----=_Part_2823_989935661.1516046875620"

------=_Part_2823_989935661.1516046875620
Content-Type: text/plain; charset="UTF-8"



On Monday, January 15, 2018 at 7:48:04 PM UTC+2, Nicol Bolas wrote:
>
> On Monday, January 15, 2018 at 4:27:27 AM UTC-5, mihailn...@gmail.com 
> wrote:
>>
>> ...
>>
>> You are not fair in your example. I was very specific - the attr will be 
>> ignored for heap allocated views (which are not that widely used, if at 
>> all). In any case an attribute can be ignored - it is just a hint - it is 
>> whole different story if its an language extension.
>>
>
> The heap allocation is irrelevant; the problem is indirect initialization 
> of the object. Consider this:
>
> template<typename T, typename ...Args>
> auto initialize(Args ...&&args)
> {
>   return T(std::forward<Args>(args)...);
> }
>
> auto var = initialize<A_view>(A{});
>
> Or even simpler:
>
> optional<A_view> ovar(in_place, A{});
>
> *Any instance* where you initialize `A_view` via forwarding will not 
> properly detect that you're using a temporary, since the forwarding 
> function cannot tell the difference between an xvalue and a prvalue.
>
> That's ultimately why I concluded that annotation-based solutions can't 
> work, that you have to create a "third reference" that preserves the 
> prvalue-ness of the argument. That is, if you want to correctly deal with 
> lifetime issues, you need to be able to tell the difference, not between 
> lvalues and rvalues, but between lvalues, xvalues, and prvalues.
>
> And technically, you need a* sixth* value category too. One that 
> represents the difference between `prvalue.member`, which is not 
> technically a prvalue but can extend the temporary's lifetime, and a 
> function call on a prvalue that returns an xvalue subobject of the prvalue, 
> which doesn't extend its lifetime.
>
> However, even for heap allocated views it will be *possible* to give a 
>> warning if view is used after A is destroyed, where it is practically 
>> impossible to extend the lifetime of A!
>>  ...
>> You have to give me an example, I am not sure I understand the issue. 
>>
>> My logic is very, very simple - as long as we have automatic variables 
>> (aka predictable destruction) the compiler knows *everything* needed to 
>> track improper use, given our specification of improper use.
>>
>  
> See above. The compiler cannot just look at the prvalue argument and an 
> attribute on the parameter to tell what's going on. `A_view` is not being 
> fed a prvalue; it's being fed an xvalue. And by all rights, that ought to 
> be fine.
>

Oh, I see. However, does it matter? Consider:

A a;
A_view ref(std::move(a));

Sure, 'a' is not a temporary, but the same rules apply and still the 
compiler has all the information it needs.

In the extend case the x/prvalue might have been important, but now they 
are not. 
The only thing that is important is to have visibility over the dtors, to 
mark the correct variable, and iff ~A is called first, the compiler will 
check for uses of ref b/w the calls of the two dtors. 

 

>
> Temporaries, prvalues these have semantic value to us, but in the end - it 
>> is the compiler just rearranging the calls the dtors. All is visible to him 
>> - he created it. 
>>
>> If we, in this predictable for the compiler world, want a variable marked 
>> so we are informed it is used before another variable from this same 
>> predictable world, I am pretty sure the compiler can do this for us.
>>
>> The point is, not want *can't* be done (the cases which will not be 
>> possible), but what *can* be done. Covering the trivial cases alone is 
>> not only better then nothing, but will actually amount to 95% of the cases 
>> needed to be covered in the first place.
>>
>
> No, half-measures are actually worse than doing nothing. Why?
>
> Because right now, we can teach people "be careful with view types and 
> temporaries". We can teach people about lifetime issues and so forth. Maybe 
> not enough programmers get this lesson, but the information is still out 
> there.
>
> But if you give people the illusion that the compiler can handle this 
> issue, that they'll get a compile error or whatever if they improperly use 
> views and temporaries, then people will use view types and temporaries with 
> abandon. They won't realize that the compiler can't catch* all* of these 
> kinds of problems. Without the training to avoid this problem, they're more 
> likely to run into it in indirect initialization cases and so forth, 
> because they have faith the compiler will tell them when they're doing it 
> wrong.
>
> If you can't solve this problem, better to do nothing at all. At least 
> then, we'll always be on our toes. Better that than to become complacent.
>


If you can't put a fence - you put a sigh.
If you can't solve the problem you give a warning (as much as you can).

And also, warnings teach better then UB!
We can teach exactly as before, the same lessons, however we put *some* 
safety nets - *for all of us. *Everyone makes mistakes - I forget return 
statements at least few times a year.

 

>
> Ultimately, I've come to believe that the only reasonable solution is 
>>> something like `extend_me`: something which explicitly extends the lifetime 
>>> of a temporary, which is the responsibility of the writer of the prvalue 
>>> expression to properly use.
>>>
>>> Actually I will not be surprised if implementations start doing that by 
>>>> themselves (warning in cases thy can verify). The question is, why the 
>>>> initiative should always come from them?
>>>>
>>>
>>> Because the interaction between two rules of the standard makes this 
>>> legal code behave in a way that is unexpected but clearly explicitly 
>>> specified.
>>>
>>
>> Does not change the fact the standard not mandating warnings, it is the 
>> implementation which must take the initiative - warning for assignment in 
>> if statement, warning for no return, for fallthrough, for empty statements, 
>> etc etc. These save lifes for pros and juniors alike. 
>>
>  
>
> Ironically all the standard did is a way to turn these warnings off if 
>> they do not match the intend. However, how about the standard turning 
>> warnings on (in cases impl. agree are implementable).
>>
>
> The standard defines behavior. Warnings are not behavior. Thus, it has no 
> right to mandate warnings.
>

I don't know. If there is behavior, then there is incorrect behavior 
(though legal code). I don't see harm of mandating warnings on incorrect 
behavior, if possible and if it is not possible for the problem to be 
solved (make the incorrect illegal).
But we are treading off topic here, as I didn't suggest a wildcard solution.
   

>  
>
>> Granted [[deprecated]] is such an example but, that is way too little, 
>> compared to what it is possible.
>>
>>
>> Sure it is better to make this code illegal, but what if it is not 
>> possible or too hard? As the saying (in my language) goes - [*It is] 
>> better [to have a]sparrow in the hand, then an eagle in the sky.*
>>
>>

-- 
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/c0383e6d-1422-403a-b1a7-43769f6be4f7%40isocpp.org.

------=_Part_2823_989935661.1516046875620
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Monday, January 15, 2018 at 7:48:04 PM UTC+2, N=
icol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr">On Monday, January 15, 2018 at 4:27:27 AM UTC-5, <a>mihailn...@gmail.co=
m</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">...<di=
v><br></div><div>You are not fair in your example. I was very specific - th=
e attr will be ignored for heap allocated views (which are not that widely =
used, if at all). In any case an attribute can be ignored - it is just a hi=
nt - it is whole different story if its an language extension.</div></div><=
/blockquote><div><br></div><div>The heap allocation is irrelevant; the prob=
lem is indirect initialization of the object. Consider this:</div><div><br>=
</div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;=
background-color:rgb(250,250,250)"><code><div><span style=3D"color:#008">te=
mplate</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#00=
8">typename</span><span style=3D"color:#000"> T</span><span style=3D"color:=
#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>typename</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">...</span><span style=3D"color:#606">Args</span><span style=3D"color:#66=
0">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"color:#0=
08">auto</span><span style=3D"color:#000"> initialize</span><span style=3D"=
color:#660">(</span><span style=3D"color:#606">Args</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">...&amp;&amp;</span><span styl=
e=3D"color:#000">args</span><span style=3D"color:#660">)</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#008">return</span><=
span style=3D"color:#000"> T</span><span style=3D"color:#660">(</span><span=
 style=3D"color:#000">std</span><span style=3D"color:#660">::</span><span s=
tyle=3D"color:#000">forward</span><span style=3D"color:#660">&lt;</span><sp=
an style=3D"color:#606">Args</span><span style=3D"color:#660">&gt;(</span><=
span style=3D"color:#000">args</span><span style=3D"color:#660">)...)<wbr>;=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}</=
span><span style=3D"color:#000"><br><br></span><span style=3D"color:#008">a=
uto</span><span style=3D"color:#000"> </span><span style=3D"color:#008">var=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D</s=
pan><span style=3D"color:#000"> initialize</span><span style=3D"color:#660"=
>&lt;</span><span style=3D"color:#000">A_view</span><span style=3D"color:#6=
60">&gt;(</span><span style=3D"color:#000">A</span><span style=3D"color:#66=
0">{});</span></div></code></div><div><br></div><div>Or even simpler:</div>=
<div><br></div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:br=
eak-word;background-color:rgb(250,250,250)"><code><div><span style=3D"color=
:#000">optional</span><span style=3D"color:#660">&lt;</span><span style=3D"=
color:#000">A_view</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"> ovar</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">in_place</span><span style=3D"color:#660">,</span><span sty=
le=3D"color:#000"> A</span><span style=3D"color:#660">{});</span></div></co=
de></div><div><br></div><div><i>Any instance</i> where you initialize `A_vi=
ew` via forwarding will not properly detect that you&#39;re using a tempora=
ry, since the forwarding function cannot tell the difference between an xva=
lue and a prvalue.</div><div><br></div><div>That&#39;s ultimately why I con=
cluded that annotation-based solutions can&#39;t work, that you have to cre=
ate a &quot;third reference&quot; that preserves the prvalue-ness of the ar=
gument. That is, if you want to correctly deal with lifetime issues, you ne=
ed to be able to tell the difference, not between lvalues and rvalues, but =
between lvalues, xvalues, and prvalues.</div><div><br></div><div>And techni=
cally, you need a<i> sixth</i> value category too. One that represents the =
difference between `prvalue.member`, which is not technically a prvalue but=
 can extend the temporary&#39;s lifetime, and a function call on a prvalue =
that returns an xvalue subobject of the prvalue, which doesn&#39;t extend i=
ts lifetime.</div><div><i><br></i></div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr"><div>However, even for heap allocated views it will b=
e <i>possible</i> to give a warning if view is used after A is destroyed, w=
here it is practically impossible to extend the lifetime of A!</div><div>=
=C2=A0...<br></div><div>You have to give me an example, I am not sure I und=
erstand the issue. </div><div><br></div><div>My logic is very, very simple =
- as long as we have automatic variables (aka predictable destruction) the =
compiler knows <i>everything</i> needed to track improper use, given our sp=
ecification of improper use.</div></div></blockquote><div>=C2=A0</div><div>=
See above. The compiler cannot just look at the prvalue argument and an att=
ribute on the parameter to tell what&#39;s going on. `A_view` is not being =
fed a prvalue; it&#39;s being fed an xvalue. And by all rights, that ought =
to be fine.</div></div></blockquote><div><br></div><div>Oh, I see. However,=
 does it matter? Consider:</div><div><font face=3D"courier new,monospace"><=
br></font></div><div><font face=3D"courier new,monospace">A a;</font></div>=
<div><font face=3D"courier new,monospace">A_view ref(std::move(a));</font><=
/div><div><font face=3D"courier new,monospace"><br></font></div><div>Sure, =
&#39;a&#39; is not a temporary, but the same rules apply and still the comp=
iler has all the information it needs.</div><div><br></div><div>In the exte=
nd case the x/prvalue might have been important, but now they are not. </di=
v><div>The only thing that is important is to have visibility over the dtor=
s, to mark the correct variable, and=C2=A0<span style=3D"display: inline !i=
mportant; float: none; background-color: transparent; color: rgb(34, 34, 34=
); font-family: &quot;Arial&quot;,&quot;Helvetica&quot;,sans-serif; font-si=
ze: 13px; font-style: normal; font-variant: normal; font-weight: 400; lette=
r-spacing: normal; orphans: 2; text-align: left; text-decoration: none; tex=
t-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-=
space: normal; word-spacing: 0px;">iff ~A is called first,</span> the compi=
ler will check for uses of <font face=3D"courier new,monospace">ref</font> =
b/w the calls of the two dtors.=C2=A0</div><div><br></div><div>=C2=A0</div>=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><br></di=
v><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>Temporaries=
, prvalues these have semantic value to us, but in the end - it is the comp=
iler just rearranging the calls the dtors. All is visible to him - he creat=
ed it. </div><div><br></div><div>If we, in this predictable for the compile=
r world, want a variable marked so we are informed it is used before anothe=
r variable from this same predictable world, I am pretty sure the compiler =
can do this for us.</div><div><br></div></div><div><div dir=3D"ltr">The poi=
nt is, not want <i>can&#39;t</i> be done (the cases which will not be possi=
ble), but what <i>can</i> be done. Covering the trivial cases alone is not =
only better then nothing, but will actually amount to 95% of the cases need=
ed to be covered in the first place.</div></div></blockquote><div><br></div=
><div><div>No, half-measures are actually worse than doing nothing. Why?</d=
iv><div><br></div><div>Because right now, we can teach people &quot;be care=
ful with view types and temporaries&quot;. We can teach people about lifeti=
me issues and so forth. Maybe not enough programmers get this lesson, but t=
he information is still out there.</div><div><br></div><div>But if you give=
 people the illusion that the compiler can handle this issue, that they&#39=
;ll get a compile error or whatever if they improperly use views and tempor=
aries, then people will use view types and temporaries with abandon. They w=
on&#39;t realize that the compiler can&#39;t catch<i> all</i> of these kind=
s of problems. Without the training to avoid this problem, they&#39;re more=
 likely to run into it in indirect initialization cases and so forth, becau=
se they have faith the compiler will tell them when they&#39;re doing it wr=
ong.</div><div><br></div><div>If you can&#39;t solve this problem, better t=
o do nothing at all. At least then, we&#39;ll always be on our toes. Better=
 that than to become complacent.</div></div></div></blockquote><div><br></d=
iv><div><span style=3D"display: inline !important; float: none; background-=
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: normal; font-weight: 400; letter-spacing: normal; orphans: 2; tex=
t-align: left; text-decoration: none; text-indent: 0px; text-transform: non=
e; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"=
> </span><span style=3D"background-color: transparent; border-bottom-color:=
 rgb(34, 34, 34); border-bottom-style: none; border-bottom-width: 0px; bord=
er-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%;=
 border-image-source: none; border-image-width: 1; border-left-color: rgb(3=
4, 34, 34); border-left-style: none; border-left-width: 0px; border-right-c=
olor: rgb(34, 34, 34); border-right-style: none; border-right-width: 0px; b=
order-top-color: rgb(34, 34, 34); border-top-style: none; border-top-width:=
 0px; color: rgb(34, 34, 34); display: inline; float: none; font-family: &a=
mp;quot;Arial&amp;quot;,&amp;quot;Helvetica&amp;quot;,sans-serif; font-size=
: 13px; font-style: normal; font-variant: normal; font-weight: 400; letter-=
spacing: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; m=
argin-top: 0px; orphans: 2; padding-bottom: 0px; padding-left: 0px; padding=
-right: 0px; padding-top: 0px; text-align: left; text-decoration: none; tex=
t-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-=
space: normal; word-spacing: 0px;"><br></span></div><div><span style=3D"bac=
kground-color: transparent; border-bottom-color: rgb(34, 34, 34); border-bo=
ttom-style: none; border-bottom-width: 0px; border-image-outset: 0; border-=
image-repeat: stretch; border-image-slice: 100%; border-image-source: none;=
 border-image-width: 1; border-left-color: rgb(34, 34, 34); border-left-sty=
le: none; border-left-width: 0px; border-right-color: rgb(34, 34, 34); bord=
er-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-family: &amp;quot;Arial&amp;quot;,&am=
p;quot;Helvetica&amp;quot;,sans-serif; font-size: 13px; font-style: normal;=
 font-variant: normal; font-weight: 400; letter-spacing: normal; margin-bot=
tom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2;=
 padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0=
px; text-align: left; text-decoration: none; text-indent: 0px; text-transfo=
rm: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing=
: 0px;">If you can&#39;t put a fence - you put a sigh.</span></div><div>If =
you can&#39;t solve the problem you give a warning (as much as you can).</d=
iv><div style=3D"background-color: transparent; border-bottom-color: rgb(34=
, 34, 34); border-bottom-style: none; border-bottom-width: 0px; border-imag=
e-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border=
-image-source: none; border-image-width: 1; border-left-color: rgb(34, 34, =
34); border-left-style: none; border-left-width: 0px; border-right-color: r=
gb(34, 34, 34); border-right-style: none; border-right-width: 0px; border-t=
op-color: rgb(34, 34, 34); border-top-style: none; border-top-width: 0px; c=
olor: rgb(34, 34, 34); font-family: &amp;quot;Arial&amp;quot;,&amp;quot;Hel=
vetica&amp;quot;,sans-serif; font-size: 13px; font-style: normal; font-vari=
ant: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; =
margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; padding-b=
ottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-a=
lign: left; text-decoration: none; text-indent: 0px; text-transform: none; =
-webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"><b=
r></div><div>And also, warnings teach better then UB!<b></b></div><div>We c=
an teach exactly as before, the same lessons, however we put <i>some</i> sa=
fety nets - <i>for all of us. </i>Everyone makes mistakes - I forget return=
 statements at least few times a year.</div><div><i><br></i></div><div>=C2=
=A0</div><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=
><br></div><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"><blockq=
uote 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>Ultimately, I&#39;ve=
 come to believe that the only reasonable solution is something like `exten=
d_me`: something which explicitly extends the lifetime of a temporary, whic=
h is the responsibility of the writer of the prvalue expression to properly=
 use.</div><div><br></div><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>Actually I will not be surprised if implementations start doi=
ng that <span>by themselves</span> (warning in cases thy can verify). The q=
uestion is, why the initiative should always come from them?</div></div></b=
lockquote><div><br></div><div>Because the interaction between two rules of =
the standard makes this legal code behave in a way that is unexpected but c=
learly explicitly specified.</div></div></blockquote><div><br></div><div>Do=
es not change the fact the standard not mandating warnings, it is the imple=
mentation which must take the initiative - warning for assignment in if sta=
tement, warning for no return, for fallthrough, for empty statements, etc e=
tc. These save lifes for pros and juniors alike.=C2=A0</div></div></blockqu=
ote><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;pad=
ding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;bord=
er-left-style:solid">=C2=A0</blockquote><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204=
,204,204);border-left-width:1px;border-left-style:solid"><i></i></blockquot=
e><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>Ironically =
all the standard did is a way to turn these warnings off if they do not mat=
ch the intend. However, how about the standard turning warnings on (in case=
s impl. agree are implementable).</div></div></blockquote><div><br></div><d=
iv>The standard defines behavior. Warnings are not behavior. Thus, it has n=
o right to mandate warnings.</div></div></blockquote><div><br></div><div>I =
don&#39;t know. If there is behavior, then there is incorrect behavior (tho=
ugh legal code). I don&#39;t see harm of mandating warnings on incorrect be=
havior, if possible and if it is not possible for the problem to be solved =
(make the incorrect illegal).</div><div>But we are treading off topic here,=
 as I didn&#39;t suggest a wildcard solution.</div><div>=C2=A0 =C2=A0</div>=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>=C2=A0</=
div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>Granted [=
[deprecated]] is such an example but, that is way too little, compared to w=
hat it is possible.</div><div><br></div><div><br></div><div>Sure it is bett=
er to make this code illegal, but what if it is not possible or too hard? A=
s the saying (in my language) goes - [<b>It is] better [to have a]<span sty=
le=3D"color:rgb(0,0,0);min-height:auto;margin-bottom:0px;margin-left:4px;ma=
rgin-right:0px;margin-top:1px;vertical-align:top;white-space:nowrap">sparro=
w in the hand, then an eagle in the sky.</span></b></div><div><br></div></d=
iv></blockquote></div></blockquote></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/c0383e6d-1422-403a-b1a7-43769f6be4f7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c0383e6d-1422-403a-b1a7-43769f6be4f7=
%40isocpp.org</a>.<br />

------=_Part_2823_989935661.1516046875620--

------=_Part_2822_1777080784.1516046875619--

.
