220 8660 <CANh-dXnytwWwS7E_BGA-xK8E-zw788TJKzM=HJdC-9JbF7+gTQ@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Jeffrey Yasskin <jyasskin@google.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: string_view::is_null()
Date: Fri, 17 Jan 2014 14:10:41 -0800
Lines: 109
Approved: news@gmane.org
Message-ID: <CANh-dXnytwWwS7E_BGA-xK8E-zw788TJKzM=HJdC-9JbF7+gTQ@mail.gmail.com>
References: <8045a4d2-721d-4725-8bb7-7a91b6f53ec8@isocpp.org>
 <186E0927-C962-4E34-AED0-E7509DD1F0A0@gmail.com> <7aad44d8-6b4e-438a-b309-bd898b994b34@isocpp.org>
 <9C2C439F-7983-4224-B272-53CAD0E2E456@gmail.com> <CANh-dXnYg=1kmm1nJdSnTXmYyfBxbLTD9b+wecT+eZm5nPkf2A@mail.gmail.com>
 <CAGg_6+Pz0gQQcY_Vq6LTMFc-4iOJvVN1O3jc3gjh0J2egBTgGg@mail.gmail.com>
 <CANh-dX=Dr35_jvxadm2HWxNk6e87y8V+Dkyiw+syBfgfdTfobw@mail.gmail.com>
 <CAPOJ94O19N207rjm73tKJSc7K55kOzYxHbY9wtXquk=_uqqMsA@mail.gmail.com>
 <8E74B747-7450-41E0-8D1E-48C2D6F81535@gmail.com> <CAGNvRgDH=X2h4K_u3zOu7gUNuQbAcNHGNh=HfCRO9qG1mmiG1w@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11c16f5e4d0d9704f031d106
X-Trace: ger.gmane.org 1389996658 20608 80.91.229.3 (17 Jan 2014 22:10:58 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 17 Jan 2014 22:10:58 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDDM34EO6QDRB5WU42LAKGQEE3Z6FCI@isocpp.org Fri Jan 17 23:11:06 2014
Return-path: <std-proposals+bncBDDM34EO6QDRB5WU42LAKGQEE3Z6FCI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oa0-f70.google.com ([209.85.219.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDDM34EO6QDRB5WU42LAKGQEE3Z6FCI@isocpp.org>)
	id 1W4Hd2-0008Kq-Dw
	for gclcip-std-proposals@m.gmane.org; Fri, 17 Jan 2014 23:11:04 +0100
Original-Received: by mail-oa0-f70.google.com with SMTP id m1sf13331668oag.5
        for <gclcip-std-proposals@m.gmane.org>; Fri, 17 Jan 2014 14:11:03 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=Nbz1JHA3B+NQqlqSDWB4vlIR0iytii9UG6qRzx0zZpE=;
        b=lZ3LwiYjLCW1Ue3hUut26pezFf0Muc8qXO37p3uZqQpvMvzI8SEHESLXBv3nK3S+g0
         /2bLAUXBoRuax4m6r+qXjSTUcCaBGd5KqZ/PXgQQ9wPqR2pp8mQaXw83vx7dLL1/WwMU
         AIB7EdOXTlbY1LD3b0IT17samgPyGIXmmXRIs8KvvEmYZ/7RLIuX0glnjUyfg6DrVJEU
         +USUtsD+ocvxoPB5tK2lpZ8Ja7u4Cg+RVD9ieI94RHctUQ3j6lkPa+WtxWNA5PqvwPUq
         wDiWuORREd1EiuUpfphDAUgYR5G/xsQPOklEMHZbHLa4RMbINz98bkkU5bTbUTnqGBDi
         JPCw==
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:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=Nbz1JHA3B+NQqlqSDWB4vlIR0iytii9UG6qRzx0zZpE=;
        b=U7b79fC+oLhcyM/PN3O9CDa30wOACZ2C+uUONKq8ymvLmieWG80RfO56QMYl5k2MZ7
         JCSFknQcIUq/MYNDKB5Yx8rYcFwpdoiTOoABr2Vy2DcWWGX1aKfKxuwhl2LvFUrB9np+
         QWm+ySgkfqTDKxutuYwDejj4mG9NoL4E3DPhPHjwp+5pw2ZKrwF2+TGOEI4/PzwuFq2h
         KRW7SW4m+qczJtYztjTjwf71DWD53n+7CPQR3DGVzf6qbMoCnGPu9natwjh5rrxFGEBs
         v/nK0xRZ13stY1IlvRfF0obNHUU3CrK4o55r2rOHGvfaEgi01G1wlheMddB5pMk+Oyw5
         VrkA==
X-Gm-Message-State: ALoCoQktByP1crLZ0l7C06a967z5OU1VOyHlY2cmx99XL/pjLemsvhk9QQpg43moSXdHWgen5hVH
X-Received: by 10.182.19.231 with SMTP id i7mr1722629obe.25.1389996663271;
        Fri, 17 Jan 2014 14:11:03 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.40.137 with SMTP id x9ls529751qgx.53.gmail; Fri, 17 Jan
 2014 14:11:02 -0800 (PST)
X-Received: by 10.140.86.230 with SMTP id p93mr7241790qgd.48.1389996662596;
        Fri, 17 Jan 2014 14:11:02 -0800 (PST)
Original-Received: from mail-qc0-x22a.google.com (mail-qc0-x22a.google.com [2607:f8b0:400d:c01::22a])
        by mx.google.com with ESMTPS id hb4si6251164qcb.94.2014.01.17.14.11.02
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 17 Jan 2014 14:11:02 -0800 (PST)
Received-SPF: pass (google.com: domain of jyasskin@google.com designates 2607:f8b0:400d:c01::22a as permitted sender) client-ip=2607:f8b0:400d:c01::22a;
Original-Received: by mail-qc0-f170.google.com with SMTP id e9so4241405qcy.29
        for <std-proposals@isocpp.org>; Fri, 17 Jan 2014 14:11:02 -0800 (PST)
X-Received: by 10.140.101.104 with SMTP id t95mr7121502qge.106.1389996662383;
 Fri, 17 Jan 2014 14:11:02 -0800 (PST)
Original-Received: by 10.229.208.138 with HTTP; Fri, 17 Jan 2014 14:10:41 -0800 (PST)
In-Reply-To: <CAGNvRgDH=X2h4K_u3zOu7gUNuQbAcNHGNh=HfCRO9qG1mmiG1w@mail.gmail.com>
X-Original-Sender: jyasskin@google.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of jyasskin@google.com designates 2607:f8b0:400d:c01::22a as permitted
 sender) smtp.mail=jyasskin@google.com;       dkim=pass header.i=@google.com;
       dmarc=pass (p=REJECT dis=NONE) header.from=google.com
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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:8660
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8660>

--001a11c16f5e4d0d9704f031d106
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Fri, Jan 17, 2014 at 2:04 PM, Daniel Kr=FCgler
<daniel.kruegler@gmail.com>wrote:

> 2014/1/17 Marshall Clow <mclow.lists@gmail.com>:
> >
> > Maybe I missed something earlier in the discussion, but I believe that
> > std::string foo { nullptr, 0 };
> >
> > is a perfectly legal way of creating an empty string.
>
> No, it is not, it undefined behaviour.
>
> > Section 21.4.2 says only:
> > basic_string(const charT* s, size_type n,
> >              const Allocator& a =3D Allocator());
> > Requires: s points to an array of at least n elements of charT.
>
> Exactly this requirement makes above code undefined. There exists an
> explicit rule in [res.on.arguments] p1 b2 for this kind of wording:
>
> "If a function argument is described as being an array, the pointer
> actually passed to the function shall
> have a value such that all address computations and accesses to
> objects (that would be valid if the
> pointer did point to the first element of such an array) are in fact
> valid."
>
>
Agreed. To mitigate this, if string_view::data() could return nullptr, I
believe we could still create strings using std::string(null_sv.begin(),
null_sv.end()).

--=20

---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--001a11c16f5e4d0d9704f031d106
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On F=
ri, Jan 17, 2014 at 2:04 PM, Daniel Kr=FCgler <span dir=3D"ltr">&lt;<a href=
=3D"mailto:daniel.kruegler@gmail.com" target=3D"_blank" class=3D"cremed">da=
niel.kruegler@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">2014/1/17 Marshall Clow &lt;<a href=3D"mailt=
o:mclow.lists@gmail.com" class=3D"cremed">mclow.lists@gmail.com</a>&gt;:<br=
>
<div class=3D"im">&gt;<br>
&gt; Maybe I missed something earlier in the discussion, but I believe that=
<br>
&gt; std::string foo { nullptr, 0 };<br>
&gt;<br>
&gt; is a perfectly legal way of creating an empty string.<br>
<br>
</div>No, it is not, it undefined behaviour.<br>
<div class=3D"im"><br>
&gt; Section 21.4.2 says only:<br>
&gt; basic_string(const charT* s, size_type n,<br>
&gt; =A0 =A0 =A0 =A0 =A0 =A0 =A0const Allocator&amp; a =3D Allocator());<br=
>
&gt; Requires: s points to an array of at least n elements of charT.<br>
<br>
</div>Exactly this requirement makes above code undefined. There exists an<=
br>
explicit rule in [res.on.arguments] p1 b2 for this kind of wording:<br>
<br>
&quot;If a function argument is described as being an array, the pointer<br=
>
actually passed to the function shall<br>
have a value such that all address computations and accesses to<br>
objects (that would be valid if the<br>
pointer did point to the first element of such an array) are in fact valid.=
&quot;<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br></font></span></blockquo=
te><div><br></div></div></div><div class=3D"gmail_extra">Agreed. To mitigat=
e this, if string_view::data() could return nullptr, I believe we could sti=
ll create strings using std::string(null_sv.begin(), null_sv.end()).</div>

</div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a11c16f5e4d0d9704f031d106--

.
