Topic: nit in N3921 string_view
Author: Peter Bigot <pab@pabigot.com>
Date: Wed, 19 Feb 2014 08:05:39 -0800 (PST)
Raw View
------=_Part_3_16587346.1392825939264
Content-Type: text/plain; charset=UTF-8
I see that nullptr is now mostly supported. There is one point to be
clarified at http://isocpp.org/files/papers/N3921.html#h5o-2: the
constructor for:
constexpr basic_string_view(const charT* str);
specifies that [str,str + traits::length(str)) must be a valid range.
My reading of N3797 section 21.2.1 is that traits::length(p) is undefined
when p is a null pointer, since it must return the smallest i such that
p[i] equals charT() and there is no such i when p is null.
Am I missing something, or does using this constructor with a pointer that
is null produce undefined behavior? Using the one with an explicit length
would be OK, but not handling this case seems...fragile.
Peter
--
---
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/.
------=_Part_3_16587346.1392825939264
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I see that nullptr is now mostly supported. There is=
one point to be clarified at http://isocpp.org/files/papers/N3921.html#h5o=
-2: the constructor for:<br><br> constexpr basic_string_view(const ch=
arT* str);<br><br>specifies that [str,str + traits::length(str)) must be a =
valid range.<br><br>My reading of N3797 section 21.2.1 is that traits::leng=
th(p) is undefined when p is a null pointer, since it must return the small=
est i such that p[i] equals charT() and there is no such i when p is null.<=
br><br>Am I missing something, or does using this constructor with a pointe=
r that is null produce undefined behavior? Using the one with an expl=
icit length would be OK, but not handling this case seems...fragile.<br><br=
>Peter<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
------=_Part_3_16587346.1392825939264--
.
Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Wed, 19 Feb 2014 08:57:26 -0800
Raw View
On Wed, Feb 19, 2014 at 8:05 AM, Peter Bigot <pab@pabigot.com> wrote:
> I see that nullptr is now mostly supported. There is one point to be
> clarified at http://isocpp.org/files/papers/N3921.html#h5o-2: the
> constructor for:
>
> constexpr basic_string_view(const charT* str);
>
> specifies that [str,str + traits::length(str)) must be a valid range.
>
> My reading of N3797 section 21.2.1 is that traits::length(p) is undefined
> when p is a null pointer, since it must return the smallest i such that p[i]
> equals charT() and there is no such i when p is null.
>
> Am I missing something, or does using this constructor with a pointer that
> is null produce undefined behavior?
Yep. This matches std::string.
--
---
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/.
.
Author: Zhihao Yuan <zy@miator.net>
Date: Wed, 19 Feb 2014 12:34:34 -0500
Raw View
On Wed, Feb 19, 2014 at 11:57 AM, Jeffrey Yasskin <jyasskin@google.com> wrote:
> On Wed, Feb 19, 2014 at 8:05 AM, Peter Bigot <pab@pabigot.com> wrote:
>> I see that nullptr is now mostly supported. There is one point to be
>> clarified at http://isocpp.org/files/papers/N3921.html#h5o-2: the
>> constructor for:
>>
>> constexpr basic_string_view(const charT* str);
>>
>> specifies that [str,str + traits::length(str)) must be a valid range.
>>
>> My reading of N3797 section 21.2.1 is that traits::length(p) is undefined
>> when p is a null pointer, since it must return the smallest i such that p[i]
>> equals charT() and there is no such i when p is null.
>>
>> Am I missing something, or does using this constructor with a pointer that
>> is null produce undefined behavior?
>
> Yep. This matches std::string.
But
string_view(nullptr, 0)
does not. Should basic_string be changed?
--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/
--
---
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/.
.
Author: "Billy O'Neal" <billy.oneal@gmail.com>
Date: Wed, 19 Feb 2014 09:57:46 -0800
Raw View
--089e012288e8e6a06d04f2c6221f
Content-Type: text/plain; charset=UTF-8
It doesn't for basic_string either. basic_string wouldn't have to be
changed -- traits::length would need to be changed to turn nullptr into 0.
Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal
On Wed, Feb 19, 2014 at 9:34 AM, Zhihao Yuan <zy@miator.net> wrote:
> On Wed, Feb 19, 2014 at 11:57 AM, Jeffrey Yasskin <jyasskin@google.com>
> wrote:
> > On Wed, Feb 19, 2014 at 8:05 AM, Peter Bigot <pab@pabigot.com> wrote:
> >> I see that nullptr is now mostly supported. There is one point to be
> >> clarified at http://isocpp.org/files/papers/N3921.html#h5o-2: the
> >> constructor for:
> >>
> >> constexpr basic_string_view(const charT* str);
> >>
> >> specifies that [str,str + traits::length(str)) must be a valid range.
> >>
> >> My reading of N3797 section 21.2.1 is that traits::length(p) is
> undefined
> >> when p is a null pointer, since it must return the smallest i such that
> p[i]
> >> equals charT() and there is no such i when p is null.
> >>
> >> Am I missing something, or does using this constructor with a pointer
> that
> >> is null produce undefined behavior?
> >
> > Yep. This matches std::string.
>
> But
>
> string_view(nullptr, 0)
>
> does not. Should basic_string be changed?
>
> --
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> ___________________________________________________
> 4BSD -- http://4bsd.biz/
>
> --
>
> ---
> 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/.
>
--
---
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/.
--089e012288e8e6a06d04f2c6221f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">It doesn't for basic_string either. basic_string would=
n't have to be changed -- traits::length would need to be changed to tu=
rn nullptr into 0.</div><div class=3D"gmail_extra"><br clear=3D"all"><div><=
div dir=3D"ltr">
<div>Billy O'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">htt=
p://stackoverflow.com/users/82320/billy-oneal</a></div>
</div></div>
<br><br><div class=3D"gmail_quote">On Wed, Feb 19, 2014 at 9:34 AM, Zhihao =
Yuan <span dir=3D"ltr"><<a href=3D"mailto:zy@miator.net" target=3D"_blan=
k">zy@miator.net</a>></span> wrote:<br><blockquote class=3D"gmail_quote"=
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Feb 19, 2014 at 11:57 AM, Jeffrey Yasskin <<a href=3D"mailto:jya=
sskin@google.com">jyasskin@google.com</a>> wrote:<br>
> On Wed, Feb 19, 2014 at 8:05 AM, Peter Bigot <<a href=3D"mailto:pab=
@pabigot.com">pab@pabigot.com</a>> wrote:<br>
>> I see that nullptr is now mostly supported. =C2=A0There is one poi=
nt to be<br>
>> clarified at <a href=3D"http://isocpp.org/files/papers/N3921.html#=
h5o-2" target=3D"_blank">http://isocpp.org/files/papers/N3921.html#h5o-2</a=
>: the<br>
>> constructor for:<br>
>><br>
>> =C2=A0 constexpr basic_string_view(const charT* str);<br>
>><br>
>> specifies that [str,str + traits::length(str)) must be a valid ran=
ge.<br>
>><br>
>> My reading of N3797 section 21.2.1 is that traits::length(p) is un=
defined<br>
>> when p is a null pointer, since it must return the smallest i such=
that p[i]<br>
>> equals charT() and there is no such i when p is null.<br>
>><br>
>> Am I missing something, or does using this constructor with a poin=
ter that<br>
>> is null produce undefined behavior?<br>
><br>
> Yep. This matches std::string.<br>
<br>
But<br>
<br>
=C2=A0 string_view(nullptr, 0)<br>
<br>
does not. =C2=A0Should basic_string be changed?<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
Zhihao Yuan, ID lichray<br>
The best way to predict the future is to invent it.<br>
___________________________________________________<br>
4BSD -- <a href=3D"http://4bsd.biz/" target=3D"_blank">http://4bsd.biz/</a>=
<br>
<br>
--<br>
<br>
---<br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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>
</font></span></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--089e012288e8e6a06d04f2c6221f--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Wed, 19 Feb 2014 12:06:21 -0600
Raw View
--f46d0444ecaf6fe95204f2c6410f
Content-Type: text/plain; charset=ISO-8859-1
On 19 February 2014 11:34, Zhihao Yuan <zy@miator.net> wrote:
>
> But
>
> string_view(nullptr, 0)
>
> does not. Should basic_string be changed?
>
I believe that it should, but it will take a paper to explore it, because
basic_string was deliberately designed that way.
It comes from the C requirements (C99 7.1.4): "If an argument to a function
has an invalid value (such as a value outside the domain of the function,
or a pointer outside the address space of the program, or a null pointer,
or a pointer to non-modifiable storage when the corresponding parameter is
not const-qualified) or a type (after promotion) not expected by a function
with variable number of arguments, the behavior is undefined." That
requirement applies to library functions such as memcpy.
*sigh* I started writing that paper in 2012... (if someone wants to
volunteer to finish it, ... :-))
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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/.
--f46d0444ecaf6fe95204f2c6410f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 19 February 2014 11:34, Zhihao Yuan <span dir=3D"ltr">&=
lt;<a href=3D"mailto:zy@miator.net" target=3D"_blank">zy@miator.net</a>>=
</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quote"><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef=
t:1px solid rgb(204,204,204);padding-left:1ex">
<div class=3D""><br>
</div>But<br>
<br>
=A0 string_view(nullptr, 0)<br>
<br>
does not. =A0Should basic_string be changed?<br clear=3D"all"></blockquote>=
<div><br></div><div>I believe that it should, but it will take a paper to e=
xplore it, because basic_string was deliberately designed that way.<br><br>
It comes from the C requirements (C99 7.1.4): "If an argument to a fun=
ction has an invalid value (such as a value outside the domain of the funct=
ion, or a pointer outside the address space of the program, or a null point=
er, or a pointer to non-modifiable storage when the corresponding parameter=
is not const-qualified) or a type (after promotion) not expected by a func=
tion with variable number of arguments, the behavior is undefined."=A0=
That requirement applies to library functions such as memcpy.<br>
<br></div><div>*sigh*=A0 I started writing that paper in 2012... (if someon=
e wants to volunteer to finish it, ... :-))<br></div></div>-- <br>=A0Nevin =
":-)" Liber=A0 <mailto:<a href=3D"mailto:nevin@eviloverlord.co=
m" target=3D"_blank">nevin@eviloverlord.com</a>>=A0 (847) 691-1404
</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--f46d0444ecaf6fe95204f2c6410f--
.
Author: Miro Knejp <miro@knejp.de>
Date: Wed, 19 Feb 2014 19:23:50 +0100
Raw View
This is a multi-part message in MIME format.
--------------090504090107010008050906
Content-Type: text/plain; charset=UTF-8; format=flowed
basic_string(nullptr, 0) does not use traits::length, so if
basic_string(nulltpr, 0) does not return nullptr from data() there is
quite a significant incompatibility between the two (libc++ gives "" in
this case).
Am 19.02.2014 18:57, schrieb Billy O'Neal:
> It doesn't for basic_string either. basic_string wouldn't have to be
> changed -- traits::length would need to be changed to turn nullptr into 0.
>
> Billy O'Neal
> https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
> http://stackoverflow.com/users/82320/billy-oneal
>
>
> On Wed, Feb 19, 2014 at 9:34 AM, Zhihao Yuan <zy@miator.net
> <mailto:zy@miator.net>> wrote:
>
> On Wed, Feb 19, 2014 at 11:57 AM, Jeffrey Yasskin
> <jyasskin@google.com <mailto:jyasskin@google.com>> wrote:
> > On Wed, Feb 19, 2014 at 8:05 AM, Peter Bigot <pab@pabigot.com
> <mailto:pab@pabigot.com>> wrote:
> >> I see that nullptr is now mostly supported. There is one point
> to be
> >> clarified at http://isocpp.org/files/papers/N3921.html#h5o-2: the
> >> constructor for:
> >>
> >> constexpr basic_string_view(const charT* str);
> >>
> >> specifies that [str,str + traits::length(str)) must be a valid
> range.
> >>
> >> My reading of N3797 section 21.2.1 is that traits::length(p) is
> undefined
> >> when p is a null pointer, since it must return the smallest i
> such that p[i]
> >> equals charT() and there is no such i when p is null.
> >>
> >> Am I missing something, or does using this constructor with a
> pointer that
> >> is null produce undefined behavior?
> >
> > Yep. This matches std::string.
>
> But
>
> string_view(nullptr, 0)
>
> does not. Should basic_string be changed?
>
> --
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> ___________________________________________________
> 4BSD -- http://4bsd.biz/
>
> --
>
> ---
> 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
> <mailto:std-proposals%2Bunsubscribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org
> <mailto:std-proposals@isocpp.org>.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
>
> --
>
> ---
> 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/.
--
---
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/.
--------------090504090107010008050906
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
</head>
<body text=3D"#000000" bgcolor=3D"#FFFFFF">
basic_string(nullptr, 0) does not use traits::length, so if
basic_string(nulltpr, 0) does not return nullptr from data() there
is quite a significant incompatibility between the two (libc++ gives
"" in this case).<br>
<br>
<div class=3D"moz-cite-prefix">Am 19.02.2014 18:57, schrieb Billy
O'Neal:<br>
</div>
<blockquote
cite=3D"mid:CAPBZbvyvLZGto9RqYNunp3e17QoDiTvRkMo5rf90kL4qZ7gEcA@mail.gmail.=
com"
type=3D"cite">
<div dir=3D"ltr">It doesn't for basic_string either. basic_string
wouldn't have to be changed -- traits::length would need to be
changed to turn nullptr into 0.</div>
<div class=3D"gmail_extra"><br clear=3D"all">
<div>
<div dir=3D"ltr">
<div>Billy O'Neal</div>
<div><a moz-do-not-send=3D"true"
href=3D"https://bitbucket.org/BillyONeal/" target=3D"_blank=
">https://github.com/BillyONeal/</a></div>
<div><a moz-do-not-send=3D"true"
href=3D"http://stackoverflow.com/users/82320/billy-oneal"
target=3D"_blank">http://stackoverflow.com/users/82320/bill=
y-oneal</a></div>
</div>
</div>
<br>
<br>
<div class=3D"gmail_quote">On Wed, Feb 19, 2014 at 9:34 AM, Zhihao
Yuan <span dir=3D"ltr"><<a moz-do-not-send=3D"true"
href=3D"mailto:zy@miator.net" target=3D"_blank">zy@miator.net=
</a>></span>
wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Feb 19, 2014 at 11:57 AM, Jeffrey Yasskin <<a
moz-do-not-send=3D"true" href=3D"mailto:jyasskin@google.com">=
jyasskin@google.com</a>>
wrote:<br>
> On Wed, Feb 19, 2014 at 8:05 AM, Peter Bigot <<a
moz-do-not-send=3D"true" href=3D"mailto:pab@pabigot.com">pab@=
pabigot.com</a>>
wrote:<br>
>> I see that nullptr is now mostly supported. =C2=A0Ther=
e
is one point to be<br>
>> clarified at <a moz-do-not-send=3D"true"
href=3D"http://isocpp.org/files/papers/N3921.html#h5o-2"
target=3D"_blank">http://isocpp.org/files/papers/N3921.html#h=
5o-2</a>:
the<br>
>> constructor for:<br>
>><br>
>> =C2=A0 constexpr basic_string_view(const charT* str);<=
br>
>><br>
>> specifies that [str,str + traits::length(str)) must
be a valid range.<br>
>><br>
>> My reading of N3797 section 21.2.1 is that
traits::length(p) is undefined<br>
>> when p is a null pointer, since it must return the
smallest i such that p[i]<br>
>> equals charT() and there is no such i when p is
null.<br>
>><br>
>> Am I missing something, or does using this
constructor with a pointer that<br>
>> is null produce undefined behavior?<br>
><br>
> Yep. This matches std::string.<br>
<br>
But<br>
<br>
=C2=A0 string_view(nullptr, 0)<br>
<br>
does not. =C2=A0Should basic_string be changed?<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
Zhihao Yuan, ID lichray<br>
The best way to predict the future is to invent it.<br>
___________________________________________________<br>
4BSD -- <a moz-do-not-send=3D"true"
href=3D"http://4bsd.biz/" target=3D"_blank">http://4bsd.b=
iz/</a><br>
<br>
--<br>
<br>
---<br>
You received this message because you are subscribed to
the Google Groups "ISO C++ Standard - Future Proposals"
group.<br>
To unsubscribe from this group and stop receiving emails
from it, send an email to <a moz-do-not-send=3D"true"
href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">st=
d-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a
moz-do-not-send=3D"true"
href=3D"mailto:std-proposals@isocpp.org">std-proposals@is=
ocpp.org</a>.<br>
Visit this group at <a moz-do-not-send=3D"true"
href=3D"http://groups.google.com/a/isocpp.org/group/std-p=
roposals/"
target=3D"_blank">http://groups.google.com/a/isocpp.org/g=
roup/std-proposals/</a>.<br>
</font></span></blockquote>
</div>
<br>
</div>
-- <br>
=C2=A0<br>
--- <br>
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it,
send an email to <a class=3D"moz-txt-link-abbreviated" href=3D"mailto=
:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org=
</a>.<br>
To post to this group, send email to <a class=3D"moz-txt-link-abbrevi=
ated" href=3D"mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>=
..<br>
Visit this group at <a moz-do-not-send=3D"true"
href=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/"=
>http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br>
</blockquote>
<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--------------090504090107010008050906--
.
Author: "Billy O'Neal" <billy.oneal@gmail.com>
Date: Wed, 19 Feb 2014 10:50:39 -0800
Raw View
--089e0149c5f6daf0a904f2c6df7e
Content-Type: text/plain; charset=UTF-8
Yes, that's correct. This discussion is about the constructor that takes a
pointer and no length.
Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal
On Wed, Feb 19, 2014 at 10:23 AM, Miro Knejp <miro@knejp.de> wrote:
> basic_string(nullptr, 0) does not use traits::length, so if
> basic_string(nulltpr, 0) does not return nullptr from data() there is quite
> a significant incompatibility between the two (libc++ gives "" in this
> case).
>
> Am 19.02.2014 18:57, schrieb Billy O'Neal:
>
> It doesn't for basic_string either. basic_string wouldn't have to be
> changed -- traits::length would need to be changed to turn nullptr into 0.
>
> Billy O'Neal
> https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
> http://stackoverflow.com/users/82320/billy-oneal
>
>
> On Wed, Feb 19, 2014 at 9:34 AM, Zhihao Yuan <zy@miator.net> wrote:
>
>> On Wed, Feb 19, 2014 at 11:57 AM, Jeffrey Yasskin <jyasskin@google.com>
>> wrote:
>> > On Wed, Feb 19, 2014 at 8:05 AM, Peter Bigot <pab@pabigot.com> wrote:
>> >> I see that nullptr is now mostly supported. There is one point to be
>> >> clarified at http://isocpp.org/files/papers/N3921.html#h5o-2: the
>> >> constructor for:
>> >>
>> >> constexpr basic_string_view(const charT* str);
>> >>
>> >> specifies that [str,str + traits::length(str)) must be a valid range.
>> >>
>> >> My reading of N3797 section 21.2.1 is that traits::length(p) is
>> undefined
>> >> when p is a null pointer, since it must return the smallest i such
>> that p[i]
>> >> equals charT() and there is no such i when p is null.
>> >>
>> >> Am I missing something, or does using this constructor with a pointer
>> that
>> >> is null produce undefined behavior?
>> >
>> > Yep. This matches std::string.
>>
>> But
>>
>> string_view(nullptr, 0)
>>
>> does not. Should basic_string be changed?
>>
>> --
>> Zhihao Yuan, ID lichray
>> The best way to predict the future is to invent it.
>> ___________________________________________________
>> 4BSD -- http://4bsd.biz/
>>
>> --
>>
>> ---
>> 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/.
>>
>
> --
>
> ---
> 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/.
>
>
> --
>
> ---
> 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/.
>
--
---
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/.
--089e0149c5f6daf0a904f2c6df7e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Yes, that's correct. This discussion is about the cons=
tructor that takes a pointer and no length.</div><div class=3D"gmail_extra"=
><br clear=3D"all"><div><div dir=3D"ltr"><div>Billy O'Neal</div><div><a=
href=3D"https://bitbucket.org/BillyONeal/" target=3D"_blank">https://githu=
b.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 Wed, Feb 19, 2014 at 10:23 AM, Miro K=
nejp <span dir=3D"ltr"><<a href=3D"mailto:miro@knejp.de" target=3D"_blan=
k">miro@knejp.de</a>></span> wrote:<br><blockquote class=3D"gmail_quote"=
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
=20
=20
=20
<div text=3D"#000000" bgcolor=3D"#FFFFFF">
basic_string(nullptr, 0) does not use traits::length, so if
basic_string(nulltpr, 0) does not return nullptr from data() there
is quite a significant incompatibility between the two (libc++ gives
"" in this case).<br>
<br>
<div>Am 19.02.2014 18:57, schrieb Billy
O'Neal:<br>
</div><div><div class=3D"h5">
<blockquote type=3D"cite">
<div dir=3D"ltr">It doesn't for basic_string either. basic_string
wouldn't have to be changed -- traits::length would need to be
changed to turn nullptr into 0.</div>
<div class=3D"gmail_extra"><br clear=3D"all">
<div>
<div dir=3D"ltr">
<div>Billy O'Neal</div>
<div><a href=3D"https://bitbucket.org/BillyONeal/" target=3D"_b=
lank">https://github.com/BillyONeal/</a></div>
<div><a href=3D"http://stackoverflow.com/users/82320/billy-onea=
l" target=3D"_blank">http://stackoverflow.com/users/82320/billy-oneal</a></=
div>
</div>
</div>
<br>
<br>
<div class=3D"gmail_quote">On Wed, Feb 19, 2014 at 9:34 AM, Zhihao
Yuan <span dir=3D"ltr"><<a href=3D"mailto:zy@miator.net" targe=
t=3D"_blank">zy@miator.net</a>></span>
wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bord=
er-left:1px #ccc solid;padding-left:1ex">
On Wed, Feb 19, 2014 at 11:57 AM, Jeffrey Yasskin <<a href=
=3D"mailto:jyasskin@google.com" target=3D"_blank">jyasskin@google.com</a>&g=
t;
wrote:<br>
> On Wed, Feb 19, 2014 at 8:05 AM, Peter Bigot <<a href=
=3D"mailto:pab@pabigot.com" target=3D"_blank">pab@pabigot.com</a>>
wrote:<br>
>> I see that nullptr is now mostly supported. =C2=A0Ther=
e
is one point to be<br>
>> clarified at <a href=3D"http://isocpp.org/files/papers=
/N3921.html#h5o-2" target=3D"_blank">http://isocpp.org/files/papers/N3921.h=
tml#h5o-2</a>:
the<br>
>> constructor for:<br>
>><br>
>> =C2=A0 constexpr basic_string_view(const charT* str);<=
br>
>><br>
>> specifies that [str,str + traits::length(str)) must
be a valid range.<br>
>><br>
>> My reading of N3797 section 21.2.1 is that
traits::length(p) is undefined<br>
>> when p is a null pointer, since it must return the
smallest i such that p[i]<br>
>> equals charT() and there is no such i when p is
null.<br>
>><br>
>> Am I missing something, or does using this
constructor with a pointer that<br>
>> is null produce undefined behavior?<br>
><br>
> Yep. This matches std::string.<br>
<br>
But<br>
<br>
=C2=A0 string_view(nullptr, 0)<br>
<br>
does not. =C2=A0Should basic_string be changed?<br>
<span><font color=3D"#888888"><br>
--<br>
Zhihao Yuan, ID lichray<br>
The best way to predict the future is to invent it.<br>
___________________________________________________<br>
4BSD -- <a href=3D"http://4bsd.biz/" target=3D"_blank">http=
://4bsd.biz/</a><br>
<br>
--<br>
<br>
---<br>
You received this message because you are subscribed to
the Google Groups "ISO C++ Standard - Future Proposals=
"
group.<br>
To unsubscribe from this group and stop receiving emails
from it, send an email to <a href=3D"mailto:std-proposals%2=
Bunsubscribe@isocpp.org" target=3D"_blank">std-proposals+unsubscribe@isocpp=
..org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-=
proposals@isocpp.org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/i=
socpp.org/group/std-proposals/" target=3D"_blank">http://groups.google.com/=
a/isocpp.org/group/std-proposals/</a>.<br>
</font></span></blockquote>
</div>
<br>
</div>
-- <br>
=C2=A0<br>
--- <br>
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it,
send an email to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.o=
rg" target=3D"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@=
isocpp.org" target=3D"_blank">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.o=
rg/group/std-proposals/</a>.<br>
</blockquote>
<br>
</div></div></div><div class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
=C2=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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 />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--089e0149c5f6daf0a904f2c6df7e--
.
Author: "Billy O'Neal" <billy.oneal@gmail.com>
Date: Wed, 19 Feb 2014 10:51:15 -0800
Raw View
--047d7b5d25e4f8d8d604f2c6e141
Content-Type: text/plain; charset=UTF-8
It comes from the C requirements (C99 7.1.4): "If an argument to a function
has an invalid value (such as a value outside the domain of the function,
or a pointer outside the address space of the program, or a null pointer,
or a pointer to non-modifiable storage when the corresponding parameter is
not const-qualified) or a type (after promotion) not expected *by a
function with variable number of arguments*, the behavior is undefined."
That requirement applies to library functions such as memcpy.
There is no function with a variable number of arguments here.
Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal
On Wed, Feb 19, 2014 at 10:06 AM, Nevin Liber <nevin@eviloverlord.com>wrote:
> On 19 February 2014 11:34, Zhihao Yuan <zy@miator.net> wrote:
>
>>
>> But
>>
>> string_view(nullptr, 0)
>>
>> does not. Should basic_string be changed?
>>
>
> I believe that it should, but it will take a paper to explore it, because
> basic_string was deliberately designed that way.
>
> It comes from the C requirements (C99 7.1.4): "If an argument to a
> function has an invalid value (such as a value outside the domain of the
> function, or a pointer outside the address space of the program, or a null
> pointer, or a pointer to non-modifiable storage when the corresponding
> parameter is not const-qualified) or a type (after promotion) not expected
> by a function with variable number of arguments, the behavior is
> undefined." That requirement applies to library functions such as memcpy.
>
> *sigh* I started writing that paper in 2012... (if someone wants to
> volunteer to finish it, ... :-))
> --
> Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
>
> --
>
> ---
> 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/.
>
--
---
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/.
--047d7b5d25e4f8d8d604f2c6e141
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><span style=3D"font-family:arial,sans-serif;font-size:13px=
">It comes from the C requirements (C99 7.1.4): "If an argument to a f=
unction has an invalid value (such as a value outside the domain of the fun=
ction, or a pointer outside the address space of the program, or a null poi=
nter, or a pointer to non-modifiable storage when the corresponding paramet=
er is not const-qualified) or a type (after promotion) not expected <b>by a=
function with variable number of arguments</b>, the behavior is undefined.=
"=C2=A0 That requirement applies to library functions such as memcpy.<=
/span><br>
<div><span style=3D"font-family:arial,sans-serif;font-size:13px"><br></span=
></div><div><span style=3D"font-family:arial,sans-serif;font-size:13px">The=
re is no function with a variable number of arguments here.</span></div></d=
iv>
<div class=3D"gmail_extra"><br clear=3D"all"><div><div dir=3D"ltr"><div>Bil=
ly O'Neal</div><div><a href=3D"https://bitbucket.org/BillyONeal/" targe=
t=3D"_blank">https://github.com/BillyONeal/</a></div><div><a href=3D"http:/=
/stackoverflow.com/users/82320/billy-oneal" target=3D"_blank">http://stacko=
verflow.com/users/82320/billy-oneal</a></div>
</div></div>
<br><br><div class=3D"gmail_quote">On Wed, Feb 19, 2014 at 10:06 AM, Nevin =
Liber <span dir=3D"ltr"><<a href=3D"mailto:nevin@eviloverlord.com" targe=
t=3D"_blank">nevin@eviloverlord.com</a>></span> wrote:<br><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;p=
adding-left:1ex">
<div dir=3D"ltr"><div class=3D"">On 19 February 2014 11:34, Zhihao Yuan <sp=
an dir=3D"ltr"><<a href=3D"mailto:zy@miator.net" target=3D"_blank">zy@mi=
ator.net</a>></span> wrote:<br></div><div class=3D"gmail_extra"><div cla=
ss=3D"gmail_quote">
<div class=3D""><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0=
px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><br>
</div>But<br>
<br>
=C2=A0 string_view(nullptr, 0)<br>
<br>
does not. =C2=A0Should basic_string be changed?<br clear=3D"all"></blockquo=
te><div><br></div></div><div>I believe that it should, but it will take a p=
aper to explore it, because basic_string was deliberately designed that way=
..<br>
<br>
It comes from the C requirements (C99 7.1.4): "If an argument to a fun=
ction has an invalid value (such as a value outside the domain of the funct=
ion, or a pointer outside the address space of the program, or a null point=
er, or a pointer to non-modifiable storage when the corresponding parameter=
is not const-qualified) or a type (after promotion) not expected by a func=
tion with variable number of arguments, the behavior is undefined."=C2=
=A0 That requirement applies to library functions such as memcpy.<br>
<br></div><div>*sigh*=C2=A0 I started writing that paper in 2012... (if som=
eone wants to volunteer to finish it, ... :-))<span class=3D"HOEnZb"><font =
color=3D"#888888"><br></font></span></div></div><span class=3D"HOEnZb"><fon=
t color=3D"#888888">-- <br>
=C2=A0Nevin ":-)" Liber=C2=A0 <mailto:<a href=3D"mailto:nevin@=
eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>>=C2=A0 <a=
href=3D"tel:%28847%29%20691-1404" value=3D"+18476911404" target=3D"_blank"=
>(847) 691-1404</a>
</font></span></div></div><div class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
=C2=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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 />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--047d7b5d25e4f8d8d604f2c6e141--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Wed, 19 Feb 2014 12:53:38 -0600
Raw View
--f46d043c06be8ea4dc04f2c6ea19
Content-Type: text/plain; charset=ISO-8859-1
On 19 February 2014 12:51, Billy O'Neal <billy.oneal@gmail.com> wrote:
> It comes from the C requirements (C99 7.1.4): "If an argument to a
> function has an invalid value (such as a value outside the domain of the
> function, or a pointer outside the address space of the program, or a *null
> pointer*, or a pointer to non-modifiable storage when the corresponding
> parameter is not const-qualified) or a type (after promotion) not expected *by
> a function with variable number of arguments*, the behavior is
> undefined." That requirement applies to library functions such as memcpy.
>
> There is no function with a variable number of arguments here.
>
No, but there is "a null pointer".
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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/.
--f46d043c06be8ea4dc04f2c6ea19
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 19 February 2014 12:51, Billy O'Neal <span dir=3D"l=
tr"><<a href=3D"mailto:billy.oneal@gmail.com" target=3D"_blank">billy.on=
eal@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra"><div clas=
s=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D""><span style=
=3D"font-family:arial,sans-serif;font-size:13px">It comes from the C requir=
ements (C99 7.1.4): "If an argument to a function has an invalid value=
(such as a value outside the domain of the function, or a pointer outside =
the address space of the program, or a <b><i>null pointer</i></b>, or a poi=
nter to non-modifiable storage when the corresponding parameter is not cons=
t-qualified) or a type (after promotion) not expected <b>by a function with=
variable number of arguments</b>, the behavior is undefined."=A0 That=
requirement applies to library functions such as memcpy.</span><br>
<div><span style=3D"font-family:arial,sans-serif;font-size:13px"><br></span=
></div></div><div><span style=3D"font-family:arial,sans-serif;font-size:13p=
x">There is no function with a variable number of arguments here.</span></d=
iv>
</div></blockquote><div><br></div><div>No, but there is "a null pointe=
r".</div></div>-- <br>=A0Nevin ":-)" Liber=A0 <mailto:<a =
href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlord=
..com</a>>=A0 (847) 691-1404
</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--f46d043c06be8ea4dc04f2c6ea19--
.