220 35377 <32147114.z48B4pQc9d@tjmaciei-mobl1> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: On P0829 - a freestanding implementation
Date: Wed, 15 Nov 2017 18:21:30 -0800
Lines: 68
Approved: news@gmane.org
Message-ID: <32147114.z48B4pQc9d@tjmaciei-mobl1>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: blaine.gmane.org 1510798896 28517 195.159.176.226 (16 Nov 2017 02:21:36 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 16 Nov 2017 02:21:36 +0000 (UTC)
Cc: Ben Craig <ben.craig@gmail.com>
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBLPMWPIAKGQEYGSLT5Y@isocpp.org Thu Nov 16 03:21:31 2017
Return-path: <std-proposals+bncBCB4TK757YBRBLPMWPIAKGQEYGSLT5Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wr0-f198.google.com ([209.85.128.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRBLPMWPIAKGQEYGSLT5Y@isocpp.org>)
	id 1eF9nz-0006qh-3o
	for gclcip-std-proposals@m.gmane.org; Thu, 16 Nov 2017 03:21:27 +0100
Original-Received: by mail-wr0-f198.google.com with SMTP id 107sf13697107wra.7
        for <gclcip-std-proposals@m.gmane.org>; Wed, 15 Nov 2017 18:21:34 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1510798894; cv=pass;
        d=google.com; s=arc-20160816;
        b=Jfbtd3taq/DeQL2O2IFapnErjXWKxNk+DlovGSl2wRGby1F3yy8i7pSfQ9qSzfZ64v
         V1byavzGX+fSHfbnh920/fXbKvppb1mUU4eiSNacepR2wp0C8Ku8VTc+bbDoff853TES
         viKJCpEuDFYNGswoAKjQUeevM78j6O/Gv1ohvj5g3JgikZItoFk2A1Zq8jpU9osL6rnc
         cBR9bcnYeXd24OVeQzIkAPC1oP6s+m/TMnf8gA4rJEcH3tQI22cI2qSajCfycnbSKb/Q
         JYDTgaxGMlj+w3HWYJWX1ikSAQg6X6JPE+w0su8jxaFgRbrmQ3Ab2csEwXCu+LaCwWJI
         CPYg==
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:mime-version:message-id
         :date:subject:cc:to:from:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=u7u1H0lr3axcCsHeW4NGAMEEubKyvRCrDK8ePKDL80U=;
        b=mKcwWWxBWa4X2q4dOU0g4BBx6qcaf1Q4nDty/3jrYov4sKTDe0m0KNQRw8cDZ/w2eX
         znm8FNCdIBslX7XOCQIQTgUa4qInNGSvoX3TfMtPNlbnGkf/hNaLn/1VjHtkJHV4mkO4
         HVy9hkLJyU20GSEf5XHw9M8PMkpzc7Q6aKeS+vpvzXG1xj/HpfJjdihSjJw916zPPAb5
         oB8fElELPecIpcH3JSUJiP8uRY+74wn1GKsU7xLBFdFRl/e/40sMesn8LhC1d5b/osil
         zLehwkdzlAnbvA+W2P1oiPQ0UWgjbMeqoBsjYYsWYyOVVjFllsDkG0gs1PRSw87P2pTA
         gRJA==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) smtp.mailfrom=thiago@macieira.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:to:cc:subject:date:message-id:mime-version: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=u7u1H0lr3axcCsHeW4NGAMEEubKyvRCrDK8ePKDL80U=;
        b=VKp8/oXloKvHKA9A53EX8QXSqeXrYwZpil6mqOMVq4TFlRnX6zxvinj9ljq7oV99ZK
         2EbsxiEfV+F8UtGrGeTWyFUdIwanyjrS50gYzoVfG0K/iutFHTvnc40fnSTaK65Wihpv
         DLxPl3t73pHmVlUWeulx4un1d2pc3UA8a2Xn7rAhTFiHhi6pKJqbcj8gYKXQmRyz2wUn
         f4VPeLUmL5LDwKB3EPqMi9xFka7Sk+XOMj3GhpCC6TZFitevNVXF+UCjQImYNxixzRC2
         TXFeeb9rDjO74nFkH+IvT5Jgc09Wr/L9n6mAAgm64WmN9LGVc4m8G/oEXfQZ16HId5Nn
         MuCQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version
         :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=u7u1H0lr3axcCsHeW4NGAMEEubKyvRCrDK8ePKDL80U=;
        b=diy2PciOn4yPiZE3Ys2D3Fn/2Ok04mkmHmqVDCL1l0VnZNey/FO1YqNb3XkUkydDQ1
         QGnNr/4bQonfIdWhPdXZnmplYTIq2Csckk0JjRMr4A2LXwWu2HWgV8XN0xbL4PD84IW2
         03AxbmHoAavoV68DLMjKg8KVQm3hEHipYJmSUlX0MJRbyU8LFqzjTsdMrpRTHJkH/BH+
         KkiSDVg9sH4rI5NhsgM4InGk6iM2ONarB3L4jAmk/Xe7QyMZn4SsFjaBiJTYd1tj92lR
         tEkrEjbjnvLTe5dWndulHFCDgTV/Y2HjV9Wgs5HpMTespPBIHlU+SDkR4Vm5Xcc8bZWd
         Qehg==
X-Gm-Message-State: AJaThX7E0hhVvPKLUB0prT8k4Qcoq4m8igZOaG4QUbyw1aEpIz9MNwfI
	k69oPB4MuqPA2QFOxpjNZOelrw==
X-Google-Smtp-Source: AGs4zMYlXv5YCbHJtH8srBXkUqsE3i9il/wVgDMBt2PfYLorB519XKY7YXZW+q3WQ1+Lfk9gdoBkjw==
X-Received: by 10.28.184.138 with SMTP id i132mr39197wmf.30.1510798894435;
        Wed, 15 Nov 2017 18:21:34 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.188.132 with SMTP id m126ls82748wmf.7.gmail; Wed, 15 Nov
 2017 18:21:33 -0800 (PST)
X-Received: by 10.28.73.196 with SMTP id w187mr250192wma.17.1510798893414;
        Wed, 15 Nov 2017 18:21:33 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1510798893; cv=none;
        d=google.com; s=arc-20160816;
        b=x0nD4ssgyYBYbzwm+08vHaeb9gcBUyvI1Obk/nzmWyIloxvgUkXCwIU86oABbUQxPY
         QvQVoaPJDESuyFKGSPse6dQ3nTkMFhfi3U5T+k9GWxQJopYeshIxV+fx1wkgBbwouseq
         tRvT4oZ3Q5kFbjGBDeoKvm2BVa/LqNb4Dzvk8TL1jtQxQYyjkVwCo0ODhod9LzIpgYAT
         FrOg62p56VejbXeNJ/ekBhityLDgFiOu+F2KhYORR7DC6ZCYF8oNphIsK9GiUxIQCgtK
         mLdNImWJQR8sznL1ibhyGJ+tGF6sAwDVfzLBs6e3g2aG1M0CMhRUSXXDbw6EmbTkKUqS
         b9CQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:arc-authentication-results;
        bh=A2tkeLj7NDl34seYn7aCmeS2D9Qf+fKwIUqmNPBl9LQ=;
        b=f4hnmveUCMJuMjHoDH7HljUplD57HtgJbWUikZ+93DXuhFmgACAXrc4jt8oyca3VSe
         08XgqylTYrKBWJuidLHSG+K7gjQlXPQ4OQl1WWDLWcmNaUbPpUxRXzHK+gVtiNRsQIbL
         IMDb1qACRUuLndcPqr4qd3boOkOOZYmd9EriduqG/9ZGGitd0lsmy1XzJBQl683+8cbc
         MEXyuqbHMA5jzZxb8sWg95v832FADToWE475KYW7qymxA35oKX2cIZqF4qXlSWOOaDGc
         ksiU8r7cphug/dFITcMgJ2w8az16E+a4JwVlybK6HERhP0vicIPRt/8XYK6ScPZLK/yA
         FvJw==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) smtp.mailfrom=thiago@macieira.org
Original-Received: from gondolin.macieira.info (gondolin.macieira.info. [78.47.120.188])
        by mx.google.com with ESMTP id j25si249601wme.187.2017.11.15.18.21.33
        for <std-proposals@isocpp.org>;
        Wed, 15 Nov 2017 18:21:33 -0800 (PST)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) client-ip=78.47.120.188;
Original-Received: from tjmaciei-mobl1.localnet (unknown [IPv6:2601:1c0:4501:5f9f:e0ee:4594:419f:8f32])
	by gondolin.macieira.info (Postfix) with ESMTPSA id B04E411B940;
	Wed, 15 Nov 2017 18:21:32 -0800 (PST)
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) smtp.mailfrom=thiago@macieira.org
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <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:35377
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35377>

First of all, let me say that the paper is a a good idea and I support the 
initiative. I also presented last year[1] at the Embedded Linux Conference 
Europe on this subject. I had a completely full room of mostly C developers 
who were interested in learning more. My presentation also had a couple more 
reasons why (IMNSHO) C++ is better than C, including const correctness and 
pointer conversions.

Second, even though a freestanding implementation is not required to have a 
heap, most do, of some sort. So even though the paper is correct in saying 
that all new except the placement one should not be required, I'd like to see 
a discussion on them being possible. The same goes for exceptions and RTTI: 
some freestanding uses may want to opt into them, even though they may have a 
certain amount of overhead.

Third, what are the criteria used for this selection? The paper talks about 
global or thread-specific storage or floating point, which I agree. Some 
functions appear to be selected for inclusion because they can be reasonably 
expected to be implemented in exclusively headers, but other ones like memcpy 
or strpbrk, usually quite complex to implement properly, are included too. 

Looking at how freestanding C does this, the selection appears to be that 
freestanding implementations are not required to provide anything that is 
usually implemented non-inline. Experience of such uses, like the Linux 
kernel, show that memcpy is expected to NOT exist and be provided by the 
application (see [2] and [3]).

A few specific comments:

* why is basic_string_view::compare not required, while memcmp is? It seems 
really weird to me that a seldom-used function like qsort is required, but 
very-often-used string comparison isn't.

* If the issue with some <cstring> functions is the use of global state, I'd 
recommend considering the reentrant portions of <string.h>, like strtok_r, 
instead.

* The ::at() functions whose only purpose is to throw an exception could 
simply be modified to not do so and do exactly the same as operator[]. That's 
for ease of porting of existing code that may use them.

* Why are the <random> distributions not included? Because all of them are 
templates, they MUST be header-only, so why exclude?

* The iostreams-using portions (operator<< and operator>>) of <random> should 
be excluded.

* As it stands, std::seed_seq requires use of the heap, so it must be 
excluded. This needs to be fixed so that non-heap use is possible. See [4].

* I agree on <variant> and <optional> and would suggest studying giving them 
non-exception interfaces. I'd be personally interested in that, since Qt could 
use them if they did not require exceptions.

[1] http://events.linuxfoundation.org/sites/events/files/slides/c++embedded.pdf
[2] https://code.woboq.org/linux/linux/lib/string.c.html#802
[3] https://code.woboq.org/linux/linux/arch/x86/lib/memcpy_64.S.html#memcpy
[4] https://groups.google.com/a/isocpp.org/d/msg/std-discussion/u_yCdZ19Bzo/
SzgMpA5zAAAJ
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

-- 
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/32147114.z48B4pQc9d%40tjmaciei-mobl1.

.
