220 8661 <CAPBZbvxFi1br+d8uacdQDvZY98zRofM5gV9aWihKdjft_x8GNA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: "Billy O'Neal" <billy.oneal@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: string_view::is_null()
Date: Fri, 17 Jan 2014 14:17:53 -0800
Lines: 162
Approved: news@gmane.org
Message-ID: <CAPBZbvxFi1br+d8uacdQDvZY98zRofM5gV9aWihKdjft_x8GNA@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=001a11c309463040c104f031ec77
X-Trace: ger.gmane.org 1389997108 26363 80.91.229.3 (17 Jan 2014 22:18:28 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 17 Jan 2014 22:18:28 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDKLBLVE6ADBBOWY42LAKGQEHD2QKLY@isocpp.org Fri Jan 17 23:18:36 2014
Return-path: <std-proposals+bncBDKLBLVE6ADBBOWY42LAKGQEHD2QKLY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oa0-f72.google.com ([209.85.219.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDKLBLVE6ADBBOWY42LAKGQEHD2QKLY@isocpp.org>)
	id 1W4HkJ-0007X3-Gh
	for gclcip-std-proposals@m.gmane.org; Fri, 17 Jan 2014 23:18:35 +0100
Original-Received: by mail-oa0-f72.google.com with SMTP id o6sf17331866oag.7
        for <gclcip-std-proposals@m.gmane.org>; Fri, 17 Jan 2014 14:18:34 -0800 (PST)
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=6r8Yf7S21zWclHbeYVNMwEFE/R+tm0X/lj/IGfqpIyQ=;
        b=kqpUsdetLpW5fej35zlSSmduU/9FtsQ/tV32Y8C8eK3ef9SRYmtKQuYoq+ovymNiyv
         D7vbpq2N6CjnGq35678KCQ4vOcYaKp+Y64gRmOmFZy7mqqdQR+JpuV5ksftyLU8jqFq7
         GzF3Zo+ZM9Fzug5vfe/NcSgANLrB/SdVJmvxHFIQYd9V3Js6YsW6hTFGpXnNLt1HhFXa
         hw1nE/iBnipBwJodFsu7dRtw+1JvuTX1I+ncSlybO0R+4V9VlXY0mQ8mIBfJpGWIshjD
         Qa9SOd3gpvuR+vLH4QlABvRlh4z5aGvu77hEeAjUZ1QFdotNKkAMlX/Fq9JiC9/4qUDI
         Gfng==
X-Gm-Message-State: ALoCoQnR8RhUipH1YYJBdznrDRgC6As8QrqA2WHIVNwXcm5ycQrgnDPF+QemQv3ALJWECO4ORxMJ
X-Received: by 10.42.64.74 with SMTP id f10mr1523510ici.12.1389997114551;
        Fri, 17 Jan 2014 14:18:34 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.23.80 with SMTP id 74ls534453qgo.61.gmail; Fri, 17 Jan
 2014 14:18:33 -0800 (PST)
X-Received: by 10.236.209.168 with SMTP id s28mr4054868yho.82.1389997113970;
        Fri, 17 Jan 2014 14:18:33 -0800 (PST)
Original-Received: from mail-oa0-x232.google.com (mail-oa0-x232.google.com [2607:f8b0:4003:c02::232])
        by mx.google.com with ESMTPS id v3si15508816yhd.38.2014.01.17.14.18.33
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 17 Jan 2014 14:18:33 -0800 (PST)
Received-SPF: pass (google.com: domain of billy.oneal@gmail.com designates 2607:f8b0:4003:c02::232 as permitted sender) client-ip=2607:f8b0:4003:c02::232;
Original-Received: by mail-oa0-f50.google.com with SMTP id n16so2255416oag.37
        for <std-proposals@isocpp.org>; Fri, 17 Jan 2014 14:18:33 -0800 (PST)
X-Received: by 10.60.50.202 with SMTP id e10mr3624145oeo.39.1389997113489;
 Fri, 17 Jan 2014 14:18:33 -0800 (PST)
Original-Received: by 10.182.87.37 with HTTP; Fri, 17 Jan 2014 14:17:53 -0800 (PST)
In-Reply-To: <CAGNvRgDH=X2h4K_u3zOu7gUNuQbAcNHGNh=HfCRO9qG1mmiG1w@mail.gmail.com>
X-Original-Sender: billy.oneal@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of billy.oneal@gmail.com designates 2607:f8b0:4003:c02::232 as
 permitted sender) smtp.mail=billy.oneal@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-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:8661
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8661>

--001a11c309463040c104f031ec77
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

>"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.=
"

So to clarify, if it were an array of size 0, you would be allowed to
increment the pointer by 1. (You would not be allowed to dereference the
pointer) You are never allowed to increment a null pointer, so data()
returning nullptr does not meet this requirement.

Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal


On Fri, Jan 17, 2014 at 2:04 PM, Daniel Kr=C3=BCgler
<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."
>
> - Daniel
>
> --
>
> ---
> 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
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--=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/.

--001a11c309463040c104f031ec77
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>&gt;&quot;If a function argument is described as bein=
g an array, the pointer=C2=A0actually passed to the function shall have a v=
alue such that all address computations and accesses to=C2=A0objects (that =
would be valid if the pointer did point to the first element of such an arr=
ay) are in fact valid.&quot;</div>

<div><br></div><div>So to clarify, if it were an array of size 0, you would=
 be allowed to increment the pointer by 1. (You would not be allowed to der=
eference the pointer) You are never allowed to increment a null pointer, so=
 data() returning nullptr does not meet this requirement.</div>

</div><div class=3D"gmail_extra"><br clear=3D"all"><div><div dir=3D"ltr"><d=
iv>Billy O&#39;Neal</div><div><a href=3D"https://bitbucket.org/BillyONeal/"=
 target=3D"_blank">https://github.com/BillyONeal/</a></div><div><a href=3D"=
http://stackoverflow.com/users/82320/billy-oneal" target=3D"_blank">http://=
stackoverflow.com/users/82320/billy-oneal</a></div>

</div></div>
<br><br><div class=3D"gmail_quote">On Fri, Jan 17, 2014 at 2:04 PM, Daniel =
Kr=C3=BCgler <span dir=3D"ltr">&lt;<a href=3D"mailto:daniel.kruegler@gmail.=
com" target=3D"_blank">daniel.kruegler@gmail.com</a>&gt;</span> wrote:<br><=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
 #ccc solid;padding-left:1ex">

2014/1/17 Marshall Clow &lt;<a href=3D"mailto:mclow.lists@gmail.com">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; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=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>
- Daniel<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
<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 <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></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 />

--001a11c309463040c104f031ec77--

.
