220 24170 <n8thcc$8va$1@ger.gmane.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Woehlke <mwoehlke.floss@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal: Change the specified behavior when
 control flow reaches the end of non-void functions
Date: Wed, 03 Feb 2016 13:36:59 -0500
Lines: 58
Approved: news@gmane.org
Message-ID: <n8thcc$8va$1@ger.gmane.org>
References: <5115b78c-8fb4-4c72-a278-f74c636f5217@isocpp.org> <n8tfc1$4v6$1@ger.gmane.org> <3004028.jdIGuf4xbV@tjmaciei-mobl4>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1454524652 9845 80.91.229.3 (3 Feb 2016 18:37:32 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 3 Feb 2016 18:37:32 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC37LBFWUIFBBXMRZG2QKGQE3W5OHVA@isocpp.org Wed Feb 03 19:37:23 2016
Return-path: <std-proposals+bncBC37LBFWUIFBBXMRZG2QKGQE3W5OHVA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f69.google.com ([209.85.215.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC37LBFWUIFBBXMRZG2QKGQE3W5OHVA@isocpp.org>)
	id 1aR2Ip-0003pU-3T
	for gclcip-std-proposals@m.gmane.org; Wed, 03 Feb 2016 19:37:19 +0100
Original-Received: by mail-lf0-f69.google.com with SMTP id j99sf11798876lfi.1
        for <gclcip-std-proposals@m.gmane.org>; Wed, 03 Feb 2016 10:37:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=to:from:subject:date:lines:message-id:references:mime-version
         :content-type:user-agent:in-reply-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=uGDI+EYBE9b05PkS+eeLVU97rMhovgG/CIsSlRo3gWI=;
        b=LFFjemhuM3oz6r6mJyhfS+bPLqjoODUrrL10VuXHu1DR3MT5vtuVo7qVLCAbfAJUaU
         jISNbSPQp+xN2ujzupZ4GwQbnF4Dy/XlbBr/Bo524/lCdWeKWtE32vTMOo38tNw6WrrF
         erod9SiCk84b8FkaTOG9x2T9RNWiesXf0n9s5OZQhXJg1MQkSs13LFJMSDy0cupRZAAl
         56NCZosIIdksCluGZhG8YmgfUUsTKE9qVr0ChS93wE0ToNrrxM/XuKomyZ3rzmioJVjY
         o76y6GQ2225+WwPI8yxMrlbZiIrAIKfsjG+1RDkYrGU/bmVULUqu9Tm/uCw7dz+mf8F3
         2EU 
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:to:from:subject:date:lines:message-id:references
         :mime-version:content-type:user-agent:in-reply-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=uGDI+EYBE9b05PkS+eeLVU97rMhovgG/CIsSlRo3gWI=;
        b=hhsMhl044lGprzjoK/5p3Q/QgkYbRZwpX+Gi7qiSgRX9U6+KJ5mLu8aaLJjlDuNqBz
         9e2auqGNBYOuVLtGmR3/dH0EdvhQuPaTFQpu6aSLfLpNieE6KGuS+xoP3ByJfJUOD+oG
         HY4u6fdUQ5HggOPZO65fp43O7yBy9XAsnl/mhMJtaC4ZJvls8k28p91kW5M26+Twdlk8
         z6cgcU19E6Sx3vO78WaNm7u3zGp0xYsAgc/+FCU+HHfSVCZW6hlmupKIwkqULn9mqdiG
         k+oJuO8eE+noiDwQUtVfDthcEM20GBfh4tdHs9l+ZlA6BPTZL6JEFiIe1bV7mDwzFD7T
         
X-Gm-Message-State: AG10YOT76zGBoM1v2Z0w4ERohEfC9n1yMwSyTXcoBjF+sXIPktLhSUbciPD3Gt2LFUi00A==
X-Received: by 10.28.172.194 with SMTP id v185mr3918832wme.5.1454524638382;
        Wed, 03 Feb 2016 10:37:18 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.25.206.13 with SMTP id e13ls151989lfg.109.gmail; Wed, 03 Feb
 2016 10:37:16 -0800 (PST)
X-Received: by 10.25.136.84 with SMTP id k81mr1612447lfd.78.1454524636754;
        Wed, 03 Feb 2016 10:37:16 -0800 (PST)
Original-Received: from plane.gmane.org (plane.gmane.org. [80.91.229.3])
        by mx.google.com with ESMTPS id n131si4779144lfn.199.2016.02.03.10.37.16
        for <std-proposals@isocpp.org>
        (version=TLS1 cipher=AES128-SHA bits=128/128);
        Wed, 03 Feb 2016 10:37:16 -0800 (PST)
Received-SPF: pass (google.com: domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as permitted sender) client-ip=80.91.229.3;
Original-Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <gclcip-std-proposals@m.gmane.org>)
	id 1aR2Il-0003iD-Hl
	for std-proposals@isocpp.org; Wed, 03 Feb 2016 19:37:15 +0100
Original-Received: from tripoint.kitware.com ([66.194.253.20])
        by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Wed, 03 Feb 2016 19:37:15 +0100
Original-Received: from mwoehlke.floss by tripoint.kitware.com with local (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Wed, 03 Feb 2016 19:37:15 +0100
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 49
Original-X-Complaints-To: usenet@ger.gmane.org
X-Gmane-NNTP-Posting-Host: tripoint.kitware.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
In-Reply-To: <3004028.jdIGuf4xbV@tjmaciei-mobl4>
X-Original-Sender: mwoehlke.floss@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as
 permitted sender) smtp.mailfrom=gclcip-std-proposals@m.gmane.org;
       dmarc=fail (p=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:24170
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/24170>

On 2016-02-03 13:21, Thiago Macieira wrote:
> On quarta-feira, 3 de fevereiro de 2016 13:02:41 PST Matthew Woehlke wrote:
>>> The reason for this is to make it easier to catch this undefined behavior
>>> by requiring the program to fail fast.
>>
>> I previously proposed to make falling off a function be ill-formed:
>> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/zu7IxDnnrNA/Yqjif
>> ANZtVsJ. I strongly encourage you to read that thread, as much of the same
>> ground has been covered already.
> 
> There's a big difference with the two proposals. To make it ill-formed, you 
> require the compiler to have absolutely no false positives or negatives.

Calling std::terminate was also brought up in that thread. Also, those
issues can be addressed with standard 'not reachable' annotation, which
is valuable in its own right.

> To make it call std::terminate(), we're only defining previously
> undefined behaviour and we don't need a 100% success rate.

....except now you're changing behavior if I *meant* to flow off the end
(e.g. because I'm doing something tricksy) to cause my program to fail
at runtime, rather than being able to detect at compile time that the
compiler wants to mangle my code.

>> ...or you could just compile with -Werror=return-type. No diligence
>> required; your code won't build and you'll *have* to fix it.
> 
> As Chris said in his OP, this does not catch everything due to false positives 
> and false negatives.

Do you actually have an example of a false positive? I've *never* seen
one, and I'm curious what such an example looks like...

> The compiler is allowed to give up if it can't prove one way or the
> other, so it often opts for assuming you know what you've done.

If the compiler can't prove an issue, does it still insert a
std::terminate? Why would it not also warn in such cases? I would
really, really hope that the compiler has a warning for any time it
inserts a std::terminate for this reason... but in that case, the value
of requiring it to insert the std::terminate becomes dubious.

This approach (terminate at run-time rather than compile-time) feels
like a cop-out to me... and yes, "perfect is the enemy of good" and all
that, but here it feels too much like laziness.

-- 
Matthew

-- 

--- 
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.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-proposals/.

.
