220 24183 <CAEhD+6B262A5dUuUOnKO7z_EnQki62OgHw0v3p_OahonSvZTwA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Andrey Semashev <andrey.semashev@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: Thu, 4 Feb 2016 02:36:22 +0300
Lines: 50
Approved: news@gmane.org
Message-ID: <CAEhD+6B262A5dUuUOnKO7z_EnQki62OgHw0v3p_OahonSvZTwA@mail.gmail.com>
References: <5115b78c-8fb4-4c72-a278-f74c636f5217@isocpp.org>
	<CAEhD+6CnZh=pHETBZ39WaaLGVovRV0CfsSJ8-qeoq1PSHz=LKw@mail.gmail.com>
	<d1c407b1-6b45-4042-8425-cdd48d53adbf@isocpp.org>
	<CAEhD+6Dwi4Mb3M-NZPqRSD+ayO8XtVYYpjGZ3HKfF4r-xL5PZg@mail.gmail.com>
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 1454542587 12388 80.91.229.3 (3 Feb 2016 23:36:27 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 3 Feb 2016 23:36:27 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCXY5TXHWYJRB545ZK2QKGQEBEF3M6Q@isocpp.org Thu Feb 04 00:36:27 2016
Return-path: <std-proposals+bncBCXY5TXHWYJRB545ZK2QKGQEBEF3M6Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f198.google.com ([209.85.160.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXY5TXHWYJRB545ZK2QKGQEBEF3M6Q@isocpp.org>)
	id 1aR6yG-0000IM-FR
	for gclcip-std-proposals@m.gmane.org; Thu, 04 Feb 2016 00:36:24 +0100
Original-Received: by mail-yk0-f198.google.com with SMTP id r207sf54771660ykd.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 03 Feb 2016 15:36:24 -0800 (PST)
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:date:message-id:subject:from:to
         :content-type: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=QrWwIrHVSn9+kkU5g17eTmcicq3J8BpSvkFY1A8+5r8=;
        b=yj/Yk4soCk5FoEDaXiXWMUGdA1eKx2P1skYGId4Iky8v1Bmq5a1Ad032XrRog/jalH
         OifQyqcV/H1QNEvP4tSBK7s1Mu/9cM3/vjVLuUYuJIFPF7ZM6YSg/WgUygwVmZ+TbtDD
         wGWogIg0I+V2mmLXjIV97NoIKVpT8BD0xIay1M3BgOetGXJI1XDJwXsaaXyrf17eVw3G
         I8GVF0sTmyPGvuodk2/+sfCarwy2goonaSHKzazHt+YodCdVQL3P/TlDxIdThzml5Tso
         UD67s8SYJKq2Tkq9iMiSjKJ8IvUqvIAD4HvH8azLGPMkRh649yzqQv6eVk9Axwl7cTIG
         kE/w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type: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=QrWwIrHVSn9+kkU5g17eTmcicq3J8BpSvkFY1A8+5r8=;
        b=lFiw+bu7on7eJFJXQnVPKAHrFw5yGT9TJRT5AbytY/P0ACuC/aH2K70IxZvUVqRy8W
         IWjhCVELqMOvkBpBsv85ydpxtuVaql1eSuC86+JbEwog/3TuvpR1Fab7OTxh7sZ21kFZ
         o5rspxwdmb3lW+6cIG9WkQIj4rX3ZY13oCUy/fP8cIh5oPtD3eYbkuoUZvapaGadKwA9
         5ElWBkmi7qO6GOiWjd8sE8bTb25CLN8WSz5epA1RmDWv40sf+DJKeMl6+Xfj9zPpOraJ
         gcApWmPIP9Q7RNBZ1jFK70XJlPNScP8aXz3/3PbbIHgbg7b73fixYlu6uHG2ZfsrVZgF
         SzWw==
X-Gm-Message-State: AG10YOTm709PY5s7b6R/0Cg0FGhs7n7v8NEElJ4tw+7QDj/KZNZvXu/FGoLYXvK7eE3cVQ==
X-Received: by 10.129.117.137 with SMTP id q131mr4195859ywc.10.1454542583697;
        Wed, 03 Feb 2016 15:36:23 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.30.3 with SMTP id e3ls744375ioe.5.gmail; Wed, 03 Feb 2016
 15:36:22 -0800 (PST)
X-Received: by 10.107.160.83 with SMTP id j80mr5977876ioe.23.1454542582867;
        Wed, 03 Feb 2016 15:36:22 -0800 (PST)
Original-Received: from mail-io0-x22f.google.com (mail-io0-x22f.google.com. [2607:f8b0:4001:c06::22f])
        by mx.google.com with ESMTPS id w62si15666479iof.21.2016.02.03.15.36.22
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 03 Feb 2016 15:36:22 -0800 (PST)
Received-SPF: pass (google.com: domain of andrey.semashev@gmail.com designates 2607:f8b0:4001:c06::22f as permitted sender) client-ip=2607:f8b0:4001:c06::22f;
Original-Received: by mail-io0-x22f.google.com with SMTP id 9so74795529iom.1
        for <std-proposals@isocpp.org>; Wed, 03 Feb 2016 15:36:22 -0800 (PST)
X-Received: by 10.107.14.73 with SMTP id 70mr6003083ioo.31.1454542582715; Wed,
 03 Feb 2016 15:36:22 -0800 (PST)
Original-Received: by 10.79.37.8 with HTTP; Wed, 3 Feb 2016 15:36:22 -0800 (PST)
In-Reply-To: <CAEhD+6Dwi4Mb3M-NZPqRSD+ayO8XtVYYpjGZ3HKfF4r-xL5PZg@mail.gmail.com>
X-Original-Sender: andrey.semashev@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of andrey.semashev@gmail.com designates 2607:f8b0:4001:c06::22f as
 permitted sender) smtp.mailfrom=andrey.semashev@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (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:24183
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/24183>

On Thu, Feb 4, 2016 at 2:19 AM, Andrey Semashev
<andrey.semashev@gmail.com> wrote:
> On Thu, Feb 4, 2016 at 2:01 AM, Nicol Bolas <jmckesson@gmail.com> wrote:
>> On Wednesday, February 3, 2016 at 5:30:53 PM UTC-5, Andrey Semashev wrote:
>>>
>>> This would incur unnecessary overhead for functions that do not return
>>> normally when the compiler is unable to see that. For example:
>>>
>>>   void throw_an_exception(const char* descr);
>>>
>>>   int make_int(bool f)
>>>   {
>>>     if (f)
>>>       return 42;
>>>     throw_an_exception("f must be true");
>>>   }
>>>
>>> throw_an_exception here does not return normally but the compiler
>>> doesn't know that unless it has access to its body. This is a quite
>>> common scenario when the code is written to reduce binary size.
>>
>> Actually, we have an annotation for that: `[[noreturn]]`. Any function so
>> marked is expressly stated to not return control to the caller. So any code
>> written after such a call should never be executed, and the compiler will
>> know that.
>
> That means that the previously fine code is now not optimal unless
> modified (i.e. marked with the attribute or somehow rearranged). I
> wouldn't like that.

I'll expand on this. What I don't like about this idea is that the
change forces the compiler to insert its voodoo magic without me
asking for it. It's as if there was 'throw()' specification for every
function by default. I want the language, in its simplest and lower
layer form, to be as close as reasonable to C. If anything, this
behavior should be optional and enabled with an attribute (i.e.
requested by the developer). I know that the argument will be that it
will be easy to forget the attribute and because of that the
usefullness of this addition will be close to zero. That is probably
true, and this is why I don't think there is point in changing the
language.

-- 

--- 
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/.

.
