220 35119 <2344937.8oWqZGD8jr@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: Re: Marking more std::string_view members noexcept
Date: Thu, 26 Oct 2017 13:37:59 -0700
Lines: 45
Approved: news@gmane.org
Message-ID: <2344937.8oWqZGD8jr@tjmaciei-mobl1>
References: <3d03cd7d-2177-98fd-408d-f74b1f6a8552@gmail.com> <1931282.giciDSTxGt@tjmaciei-mobl1> <1f284e0dd9faeabf60b45140e4c1a2b3@kdab.com>
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 1509050292 483 195.159.176.226 (26 Oct 2017 20:38:12 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 26 Oct 2017 20:38:12 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBKMPZHHQKGQEJWQGF7Q@isocpp.org Thu Oct 26 22:38:07 2017
Return-path: <std-proposals+bncBCB4TK757YBRBKMPZHHQKGQEJWQGF7Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f72.google.com ([74.125.82.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRBKMPZHHQKGQEJWQGF7Q@isocpp.org>)
	id 1e7ouZ-0006r8-H8
	for gclcip-std-proposals@m.gmane.org; Thu, 26 Oct 2017 22:37:55 +0200
Original-Received: by mail-wm0-f72.google.com with SMTP id k9sf1363822wmg.11
        for <gclcip-std-proposals@m.gmane.org>; Thu, 26 Oct 2017 13:38:03 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1509050283; cv=pass;
        d=google.com; s=arc-20160816;
        b=urqMIq2uHbGfUYiDykjEj7ivghEE3If2l0soPRdo5gOs1H4f2fVQRK+wS7JmdGH5cc
         FHwDRInOqi1nvtXmVm6PknQxwc3T9wxksG+WgSx6acGQVEwAt3rbeMucly1v4Dqu9QSv
         z5tCUiM4MpG/cdp9H1Y3NHuZ8x8GEYeZkvwsGyotTKTgyXRpoZg0o1fiXp8SZ8K1F3As
         HyJb+0YVDlAaRi6MMetTdx3MkVD1E37VWVBty3s0nndRuCyMdoxwwLXZ0oJgNt5b21YH
         AExqFuJlHjsDHgCL3Tdb1vLx4lyE4JmSxLA6zdL0DR6a/dChTN+08IiCRgvNMSGF75R3
         YU3Q==
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:references
         :in-reply-to:message-id:date:subject:to:from
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=T/E1+uYsWNkA6FZRAEFxxDlbcvgDSKRIKeo96N9t8MA=;
        b=T7fu/2NMlGFZmkiHzIH/LV3fQYH8CSlykAAuEPmyYXhfn9tJaJ3lIR0kXc6leI5jyK
         weTKaOmYDlazTUhYrtXN6Eug5Op3OQWy/h84atGndRH4LQY3w2HGnGmIPiZmt8ygNrYH
         I0ZhTvFEo+Xvznvl2UXmT3RFC4aF1+JEj2G//lj1c6Gd07mVmMBODs3JkmVtfLYIj2kf
         3a1JGOTfTSI333WVhZoEP/2HR9iREd7nvHcPZYQKJZfDGM2bcTkxyt2l/zWV2L5LCV7J
         JZLLe427YPjj9Pv8kLX00TckyZbMRp1+2paOv0J1KqfOIxG60zuTAzfyUesqOyExQCSZ
         tMLQ==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 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:subject:date:message-id:in-reply-to:references: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=T/E1+uYsWNkA6FZRAEFxxDlbcvgDSKRIKeo96N9t8MA=;
        b=cVHatDjpe8XJLF/nx94ekjVHADjfTH1mdqIM/n1aHPlQLvL8quneXC1dvUMCCCue+s
         f3Ui0Vg2L7cUfUYje8bmZXicPENjTNhxwCAN/nfVZ/xteJ1JhWyuJX54QmbaooX05e5g
         3CMi6UYClF+3qnwCHLNYCYBot7/sjNvYSvTb4dd6rXX9UDQ/Ac0HlT14lwCmMUCShVoL
         Tr63wD1aXxVObqOEw3rK4wR+QsuShBEgFL/KoTGkpDaETJS7MXQ45gahqQpdGYSgCmMd
         pSgLrjjEf92yrfLObXsyHtjComo9wGij5drsFqU9wO5NaEZMuXpsEgTkdXgFB8zldWoG
         9kww==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
         :references: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=T/E1+uYsWNkA6FZRAEFxxDlbcvgDSKRIKeo96N9t8MA=;
        b=SL3lz3ZqhF+WKP681O3hQPiXuBe1NTlwXxG8kh5drGR3bPw6V0+XQbiOOXmaR3QFan
         b2Zj8p/Fmzm8Viw55jcYDUF+SGrqJtJjrXdjz1OyaNL05FvBr4HoUUaeb8DlzL6ijKRG
         SO4WC0Ji/yc7/FiSctPJo7ph13dPvIHXcN8VKnn0WS+mOz6Ug1yI9R+3ES3gRJU79WH8
         nL4pxPDeb6BXsjxQDhxEJL3lB5KWxPHzy3H/1lhfuWmEdl8nXg4UQCk0+YZLBJT/Lfxf
         oXbTsXAvp8TU5G3mrAZSWgfIGPLgi6GLXVkRsnJk5FORR4zZNvY4fnXL3HiUreuqVGCS
         zk4Q==
X-Gm-Message-State: AMCzsaVtNB/KEhETRD0+zSzXqNZbmdtgEtlTfrwebk7aYrxuI2V2ttDw
	B/ewb4L2EwKcoiVvTVR9/wkrkA==
X-Google-Smtp-Source: ABhQp+REVDoxNR9247QpKDEHrg29/1wvqpAoL408EronOzldAUR8VjsAcstUwKiXOnBP/kpqKqYEYQ==
X-Received: by 10.28.135.147 with SMTP id j141mr14727wmd.11.1509050283056;
        Thu, 26 Oct 2017 13:38:03 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.47.194 with SMTP id v185ls95941wmv.9.canary-gmail; Thu, 26
 Oct 2017 13:38:01 -0700 (PDT)
X-Received: by 10.223.176.57 with SMTP id f54mr7017631wra.126.1509050281557;
        Thu, 26 Oct 2017 13:38:01 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1509050281; cv=none;
        d=google.com; s=arc-20160816;
        b=vaaC52a4vMaIcGwD3XkHc/IfcEWY1sIUQFxp3Pr2wVxFRXL0+7gvoNNCxNq/dWjglU
         ual3QU7dLDjMSusX3jGL8upZkcoDe6cRdhS9FWIAqzEnkaM3b5Fb9+F9tysauI3jDMW8
         DnsOCR0qKFyRGAF9FbtolL+El0/MIcGhCFSZKs6AAx00jiXlNhd5+KD0i9T39tzCV53F
         Fn+gC+icx+XBUT9Yh28gO1UqD2SpLCCC7YHi3l7g7AiyNABvh05BsYUjmZZ2h2EPIjci
         U3tjXgzPeOlFE7Bc3A7Aghk79d66TRk24Ae2NsjP/ykYBBYuiQDVNi5h2+JYp0pARRsC
         tBqw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:to:from:arc-authentication-results;
        bh=E/2DtPFNTJ8wAYMJcqqeKBZLrs4mX92DBrfigDaiLAc=;
        b=QXPf6OlkwsWvBYY4YzWyoqsRNZB84bsBQ/qLqp9rWF1i9blCsgTnGE6AUc6CMsoVwg
         0uVJFOLyqLr0HR0DjoU9oIWeDdInUJjY8i4zKh1UGELj8nqR/GDGhwiRBWu3d2gxvkbo
         idQoomyZNK8K4Lp528rt7pW132I9ilNvKoex+6qA/HUJpW1XkS/pzAr5wuc+0X5N+rtl
         bcVuWBKjk359o6+y8aHmFlSBVL7wGRzFNC4I3T1g0yD/qwnlJ8UiBWKtNtJGSsJowhOz
         GJsTgkdXRzk9UJZHRHE/v1x5M1w9AOS7YXK5kLXwqKjAReRTiaoaOdZFWngN/GsPHaDJ
         cNHQ==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) smtp.mailfrom=thiago@macieira.org
Original-Received: from gondolin.macieira.info (gondolin.macieira.info. [2a01:4f8:d13:f81:21c:14ff:fe01:12a3])
        by mx.google.com with ESMTP id k67si84794wmi.159.2017.10.26.13.38.01
        for <std-proposals@isocpp.org>;
        Thu, 26 Oct 2017 13:38:01 -0700 (PDT)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) client-ip=2a01:4f8:d13:f81:21c:14ff:fe01:12a3;
Original-Received: from tjmaciei-mobl1.localnet (fmdmzpr04-ext.fm.intel.com [192.55.54.39])
	by gondolin.macieira.info (Postfix) with ESMTPSA id 28EFE11B5C3
	for <std-proposals@isocpp.org>; Thu, 26 Oct 2017 13:38:01 -0700 (PDT)
In-Reply-To: <1f284e0dd9faeabf60b45140e4c1a2b3@kdab.com>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3
 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:35119
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35119>

On Thursday, 26 October 2017 10:44:04 PDT Marc Mutz wrote:
> On 2017-10-26 18:09, Thiago Macieira wrote:
> > No, it's not constexpr at all, since I can't run SSE or do
> > reinterpret_cast
> > from pointer to integer and back in constexpr mode.
> > 
> > See http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/tools/
> > qstring.cpp#n163
> 
> You'd think compilers would recognize an inlined strlen call and throw
> their own vectoriser at it, no? If not strlen, what else could they
> possibly auto-vectorise at all? :)

I would. That's what GCC does:

https://code.woboq.org/gcc/libstdc++-v3/include/bits/char_traits.h.html#267

But note how that's only specialised for char_traits<char> and 
char_traits<wchar_t>. 

Also note how the constexpr keyword is commented out in this listing. 
Unfortunately, Woboq has an older version of GCC; version 7 introduced that 
__builtin_constant_p trick that I mentioned for char and wchar_t.

> And, yes, you can call such functions in constexpr functions: Just loop
> inline for, say, 64bytes and, if you haven't found the end by then, call
> the out-of-line hand-optimized function to do the rest.

That's doubly bad in my opinion:
1) it looks constexpr, but isn't for some data, leading to surprises. You 
can't rely on it to create a constexpr QStringView.

2) it inserts that loop into user code that does 1 to 32 2-byte loads, instead 
of the much faster 1 to 5 16-byte memory loads.

-- 
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/2344937.8oWqZGD8jr%40tjmaciei-mobl1.

.
