Topic: Local constexpr variables and static storage duration
Author: Columbo <r.hl@gmx.net>
Date: Mon, 2 Nov 2015 14:04:51 -0800 (PST)
Raw View
------=_Part_4388_1085223667.1446501891823
Content-Type: multipart/alternative;
boundary="----=_Part_4389_1147885575.1446501891824"
------=_Part_4389_1147885575.1446501891824
Content-Type: text/plain; charset=UTF-8
Is it possible to let local variables declared with constexpr have static storage
duration? Since every constexpr variables's initializer can neither depend
upon parameter values nor dynamically initialized (or modifiable) global
state, they may as well have static storage duration with static
initialization AFAICS. Would that introduce any problems or have
significant impacts? Note that it would allow reasonable things that are
currently disallowed, e.g.
void f() {
constexpr int arr[] {1, 2, 3};
constexpr auto p = arr;
}
--
---
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_4389_1147885575.1446501891824
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Is it possible to let local variables declared with=C2=A0<=
font face=3D"courier new, monospace">constexpr</font>=C2=A0have=C2=A0<font =
face=3D"courier new, monospace">static</font>=C2=A0storage duration? Since =
every=C2=A0<font face=3D"courier new, monospace">constexpr</font>=C2=A0vari=
ables's initializer can neither depend upon parameter values nor dynami=
cally initialized (or modifiable) global state, they may as well have stati=
c storage duration with static initialization AFAICS. =C2=A0Would that intr=
oduce any problems or have significant impacts? Note that it would allow re=
asonable things that are currently disallowed, e.g.<div class=3D"prettyprin=
t" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; ba=
ckground-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><font color=3D"#000088"><div class=3D"subprettyprint">v=
oid f() {</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 constexpr int ar=
r[] {1, 2, 3};=C2=A0</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 const=
expr auto p =3D arr;</div><div class=3D"subprettyprint">}</div></font></div=
></code></div><div><br></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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_4389_1147885575.1446501891824--
------=_Part_4388_1085223667.1446501891823--
.
Author: David Krauss <potswa@gmail.com>
Date: Tue, 3 Nov 2015 11:52:46 +0800
Raw View
--Apple-Mail=_68B7EC1D-4C98-40B9-AEE9-001B160471B5
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9311=E2=80=9303, at 6:04 AM, Columbo <r.hl@gmx.net> wrote:
>=20
> Is it possible to let local variables declared with constexpr have static=
storage duration? Since every constexpr variables's initializer can neithe=
r depend upon parameter values nor dynamically initialized (or modifiable) =
global state, they may as well have static storage duration with static ini=
tialization AFAICS. =20
Static storage and initialization aren=E2=80=99t necessarily better. The sc=
heme uses less space while a function is recursing (it has at least two act=
ive stack frames), but potentially more space when it=E2=80=99s not executi=
ng. It may also reduce cache locality.
> Would that introduce any problems or have significant impacts?
It would violate object uniqueness.
On the other hand, this is an area where some flexibility might be found. A=
lready, sequence elements in std::initializer_list arrays are de-facto not =
guaranteed uniqueness. If it=E2=80=99s treated as an optional optimization =
(outside the as-if rule) instead of a requirement, then your proposal more=
-or-less comes down to allocating constexpr local variables as if they were=
inside initializer lists.
Separately but similarly, I think it would be nice to un-uniquefy all prval=
ue expressions (except when bound to non-const references). In any case, I=
=E2=80=99m not aware of much practical value to static storage outside of l=
arge tables. This is the problem domain of initializer_list, however, it ha=
s its own issues.
> Note that it would allow reasonable things that are currently disallowed,=
e.g.
> void f() {
> constexpr int arr[] {1, 2, 3};=20
> constexpr auto p =3D arr;
> }
This works on GCC:
constexpr std::initializer_list< int > il =3D { 1, 2, 3 };
constexpr int const * p =3D il.begin();
Clang rejects this, I guess because the initializer_list stores a pointer t=
o the first element of the array and not a pointer to the entire array obje=
ct, and because it validates the =E2=80=9Cpermitted result of a constant ex=
pression=E2=80=9D rule before applying the static storage optimization. I t=
hink that both are conforming, or at least, GCC is being reasonable :P .
Of course, for cases such as this where static storage is required, you sho=
uld simply declare the variable as static. With that adjustment, both of ou=
r examples work portably.
--=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/.
--Apple-Mail=_68B7EC1D-4C98-40B9-AEE9-001B160471B5
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9311=
=E2=80=9303, at 6:04 AM, Columbo <<a href=3D"mailto:r.hl@gmx.net" class=
=3D"">r.hl@gmx.net</a>> wrote:</div><br class=3D"Apple-interchange-newli=
ne"><div class=3D""><div dir=3D"ltr" class=3D"">Is it possible to let local=
variables declared with <font face=3D"courier new, monospace" class=
=3D"">constexpr</font> have <font face=3D"courier new, monospace"=
class=3D"">static</font> storage duration? Since every <font fac=
e=3D"courier new, monospace" class=3D"">constexpr</font> variables's i=
nitializer can neither depend upon parameter values nor dynamically initial=
ized (or modifiable) global state, they may as well have static storage dur=
ation with static initialization AFAICS. </div></div></blockquote><di=
v><br class=3D""></div><div>Static storage and initialization aren=E2=80=99=
t necessarily better. The scheme uses less space while a function is recurs=
ing (it has at least two active stack frames), but potentially more space w=
hen it=E2=80=99s not executing. It may also reduce cache locality.</div><br=
class=3D""><blockquote type=3D"cite" class=3D""><div class=3D""><div dir=
=3D"ltr" class=3D"">Would that introduce any problems or have significant i=
mpacts?</div></div></blockquote><div><br class=3D""></div><div>It would vio=
late object uniqueness.</div><div><br class=3D""></div><div>On the other ha=
nd, this is an area where some flexibility might be found. Already, sequenc=
e elements in <font face=3D"Courier" class=3D"">std::initializer_list</font=
> arrays are de-facto not guaranteed uniqueness. If it=E2=80=99s treated as=
an optional optimization (outside the as-if rule) instead of a requirement=
, then your proposal more-or-less comes down to allocating constexpr =
local variables as if they were inside initializer lists.</div><div><br cla=
ss=3D""></div><div>Separately but similarly, I think it would be nice to un=
-uniquefy all prvalue expressions (except when bound to non-const reference=
s). In any case, I=E2=80=99m not aware of much practical value to static st=
orage outside of large tables. This is the problem domain of <font fac=
e=3D"Courier" class=3D"">initializer_list</font>, however, it has its own i=
ssues.</div><div><br class=3D""></div><blockquote type=3D"cite" class=3D"">=
<div class=3D""><div dir=3D"ltr" class=3D""> Note that it would allow reaso=
nable things that are currently disallowed, e.g.<div class=3D"prettyprint" =
style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backg=
round-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D=
"subprettyprint"><font color=3D"#000088" class=3D""><div class=3D"subpretty=
print">void f() {</div><div class=3D"subprettyprint"> constexp=
r int arr[] {1, 2, 3}; </div><div class=3D"subprettyprint"> &nbs=
p; constexpr auto p =3D arr;</div><div class=3D"subprettyprint">}</div></fo=
nt></div></code></div></div></div></blockquote><div><br class=3D""></div><d=
iv>This works on GCC:</div><div><br class=3D""></div><div><font face=3D"Cou=
rier" class=3D"">constexpr std::initializer_list< int > il =3D { 1, 2=
, 3 };</font></div><div><font face=3D"Courier" class=3D"">constexpr int con=
st * p =3D il.begin();<br class=3D""></font><br class=3D""></div><div>Clang=
rejects this, I guess because the <span style=3D"font-family: Courier=
;" class=3D"">initializer_list</span> stores a pointer to the first el=
ement of the array and not a pointer to the entire array object, and becaus=
e it validates the =E2=80=9Cpermitted result of a constant expression=E2=80=
=9D rule before applying the static storage optimization. I think that both=
are conforming, or at least, GCC is being reasonable :P .</div><div><=
br class=3D""></div><div>Of course, for cases such as this where static sto=
rage is required, you should simply declare the variable as <font face=3D"C=
ourier" class=3D"">static</font>. With that adjustment, both of our example=
s work portably.</div><div><br class=3D""></div></div></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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_68B7EC1D-4C98-40B9-AEE9-001B160471B5--
.
Author: Columbo <r.hl@gmx.net>
Date: Tue, 3 Nov 2015 01:07:20 -0800 (PST)
Raw View
------=_Part_86_883521755.1446541641060
Content-Type: multipart/alternative;
boundary="----=_Part_87_451810761.1446541641060"
------=_Part_87_451810761.1446541641060
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Tuesday, November 3, 2015 at 3:52:57 AM UTC, David Krauss wrote:
>
> The scheme uses less space while a function is recursing (it has at least=
=20
> two active stack frames), but potentially more space when it=E2=80=99s no=
t=20
> executing. It may also reduce cache locality.
>
Do implementations not elide code and static local variables for functions=
=20
that are never called? As a link-time optimization?
=20
> On the other hand, this is an area where some flexibility might be found.=
=20
> Already, sequence elements in std::initializer_list arrays are de-facto=
=20
> not guaranteed uniqueness.
>
How is that? All these sequence elements are copied into a const array, and=
=20
[intro.object]/6 guarantees that the elements have distinct addresses. If=
=20
some of them were overlapping, that would not give the desired behavior for=
=20
iteration.
Note that it would allow reasonable things that are currently disallowed,=
=20
> e.g.
> void f() {
> constexpr int arr[] {1, 2, 3};=20
> constexpr auto p =3D arr;
> }
>
>
> This works on GCC:
>
> constexpr std::initializer_list< int > il =3D { 1, 2, 3 };
> constexpr int const * p =3D il.begin();
>
> Clang rejects this, I guess because the initializer_list stores a pointer=
=20
> to the first element of the array and not a pointer to the entire array=
=20
> object, and because it validates the =E2=80=9Cpermitted result of a const=
ant=20
> expression=E2=80=9D rule before applying the static storage optimization.=
I think=20
> that both are conforming, or at least, GCC is being reasonable :P.
>
The array held is temporary, thus not having static storage duration. Hence=
=20
the "permitted result" rule is guaranteed to apply, AFAICS.=20
--=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/.
------=_Part_87_451810761.1446541641060
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Tuesday, November 3, 2015 at 3:52:57 AM UTC, David Krau=
ss wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wr=
ap:break-word"><div><div>The scheme uses less space while a function is rec=
ursing (it has at least two active stack frames), but potentially more spac=
e when it=E2=80=99s not executing. It may also reduce cache locality.</div>=
</div></div></blockquote><div>Do implementations not elide code and static =
local variables for functions that are never called? As a link-time optimiz=
ation?</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><=
div style=3D"word-wrap:break-word"><div>On the other hand, this is an area =
where some flexibility might be found. Already, sequence elements in <font =
face=3D"Courier">std::initializer_list</font> arrays are de-facto not guara=
nteed uniqueness.</div></div></blockquote><div>How is that? All these seque=
nce elements are copied into a <font face=3D"courier new, monospace">const<=
/font> array,=C2=A0and [intro.object]/6 guarantees that the elements have d=
istinct addresses. If some of them were overlapping, that would not give th=
e desired behavior for iteration.</div><div><br></div><blockquote class=3D"=
gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc so=
lid;padding-left: 1ex;"><div style=3D"word-wrap:break-word"><blockquote typ=
e=3D"cite"><div><div dir=3D"ltr">Note that it would allow reasonable things=
that are currently disallowed, e.g.<div style=3D"border:1px solid rgb(187,=
187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div=
><font color=3D"#000088"><div>void f() {</div><div>=C2=A0 =C2=A0 constexpr =
int arr[] {1, 2, 3};=C2=A0</div><div>=C2=A0 =C2=A0 constexpr auto p =3D arr=
;</div><div>}</div></font></div></code></div></div></div></blockquote><div>=
<br></div><div>This works on GCC:</div><div><br></div><div><font face=3D"Co=
urier">constexpr std::initializer_list< int > il =3D { 1, 2, 3 };</fo=
nt></div><div><font face=3D"Courier">constexpr int const * p =3D il.begin()=
;<br></font><br></div><div>Clang rejects this, I guess because the=C2=A0<sp=
an style=3D"font-family:Courier">initializer_list</span>=C2=A0stores a poin=
ter to the first element of the array and not a pointer to the entire array=
object, and because it validates the =E2=80=9Cpermitted result of a consta=
nt expression=E2=80=9D rule before applying the static storage optimization=
.. I think that both are conforming, or at least, GCC is being reasonable :P=
..</div></div></blockquote><div>The array held is temporary, thus not having=
static storage duration. Hence the "permitted result" rule is gu=
aranteed to apply, AFAICS.=C2=A0</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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_87_451810761.1446541641060--
------=_Part_86_883521755.1446541641060--
.
Author: Columbo <r.hl@gmx.net>
Date: Tue, 3 Nov 2015 01:15:51 -0800 (PST)
Raw View
------=_Part_246_1050974542.1446542151824
Content-Type: multipart/alternative;
boundary="----=_Part_247_1857334836.1446542151824"
------=_Part_247_1857334836.1446542151824
Content-Type: text/plain; charset=UTF-8
On Tuesday, November 3, 2015 at 9:07:21 AM UTC, Columbo wrote:
>
> The array held is temporary, thus not having static storage duration.
> Hence the "permitted result" rule is guaranteed to apply, AFAICS.
>
Sorry, I have to rectify that first sentence: The array does not have
static storage duration unless the initializer_list does. So actually, in
namespace scope, your program should compile.
--
---
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_247_1857334836.1446542151824
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Tuesday, November 3, 2015 at 9:07:21 AM UTC, Columbo wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>The =
array held is temporary, thus not having static storage duration. Hence the=
"permitted result" rule is guaranteed to apply, AFAICS.=C2=A0</d=
iv></div></blockquote><div>Sorry, I have to rectify that first sentence: Th=
e array does not have static storage duration unless the <font face=3D"cour=
ier new, monospace">initializer_list</font> does. So actually, in namespace=
scope, your program should compile.</div><div><br></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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_247_1857334836.1446542151824--
------=_Part_246_1050974542.1446542151824--
.
Author: David Krauss <potswa@gmail.com>
Date: Tue, 3 Nov 2015 22:12:14 +0800
Raw View
--Apple-Mail=_5067B9A7-C8A7-4E9C-AD6B-8AC978DE23F2
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> On 2015=E2=80=9311=E2=80=9303, at 5:07 PM, Columbo <r.hl@gmx.net> wrote:
>=20
> On Tuesday, November 3, 2015 at 3:52:57 AM UTC, David Krauss wrote:
> The scheme uses less space while a function is recursing (it has at least=
two active stack frames), but potentially more space when it=E2=80=99s not=
executing. It may also reduce cache locality.
> Do implementations not elide code and static local variables for function=
s that are never called? As a link-time optimization?
Yes, but that=E2=80=99s something else. I=E2=80=99m talking about a functio=
n which isn=E2=80=99t executing at the moment, not one which is completely =
unused.
> On the other hand, this is an area where some flexibility might be found.=
Already, sequence elements in std::initializer_list arrays are de-facto no=
t guaranteed uniqueness.
> How is that? All these sequence elements are copied into a const array, a=
nd [intro.object]/6 guarantees that the elements have distinct addresses. I=
f some of them were overlapping, that would not give the desired behavior f=
or iteration.
The arrays of two initializer_list objects may not be distinct, despite [dc=
l.init.list] =C2=A78.5.4/5-6 specifying one array per list object. The elem=
ents in the array are sequential and distinct.
> On 2015=E2=80=9311=E2=80=9303, at 5:15 PM, Columbo <r.hl@gmx.net> wrote:
>=20
> On Tuesday, November 3, 2015 at 9:07:21 AM UTC, Columbo wrote:
> The array held is temporary, thus not having static storage duration. Hen=
ce the "permitted result" rule is guaranteed to apply, AFAICS.=20
> Sorry, I have to rectify that first sentence: The array does not have sta=
tic storage duration unless the initializer_list does. So actually, in name=
space scope, your program should compile.
To be clear, my example was at function scope, as yours was. The initialize=
r_list static array storage optimization is not strictly conforming, but th=
e intent was always to allow it, and all the implementations, to my knowled=
ge, do it. That=E2=80=99s why I called it =E2=80=9Cde-facto.=E2=80=9D If yo=
u find this confusing, feel free to submit a defect report.
--=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/.
--Apple-Mail=_5067B9A7-C8A7-4E9C-AD6B-8AC978DE23F2
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><div class=3D""><b=
r class=3D""></div><blockquote type=3D"cite" class=3D""><div class=3D"">On =
2015=E2=80=9311=E2=80=9303, at 5:07 PM, Columbo <<a href=3D"mailto:r.hl@=
gmx.net" class=3D"">r.hl@gmx.net</a>> wrote:</div><br class=3D"Apple-int=
erchange-newline"><div class=3D""><div dir=3D"ltr" class=3D"">On Tuesday, N=
ovember 3, 2015 at 3:52:57 AM UTC, David Krauss wrote:<blockquote class=3D"=
gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; bo=
rder-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left=
: 1ex;"><div class=3D"" style=3D"word-wrap: break-word;"><div class=3D""><d=
iv class=3D"">The scheme uses less space while a function is recursing (it =
has at least two active stack frames), but potentially more space when it=
=E2=80=99s not executing. It may also reduce cache locality.</div></div></d=
iv></blockquote><div class=3D"">Do implementations not elide code and stati=
c local variables for functions that are never called? As a link-time optim=
ization?</div></div></div></blockquote><div class=3D""><br class=3D""></div=
><div class=3D"">Yes, but that=E2=80=99s something else. I=E2=80=99m talkin=
g about a function which isn=E2=80=99t executing at the moment, not one whi=
ch is completely unused.</div><br class=3D""><blockquote type=3D"cite" clas=
s=3D""><div class=3D""><div dir=3D"ltr" class=3D""><blockquote class=3D"gma=
il_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; borde=
r-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1=
ex;"><div class=3D"" style=3D"word-wrap: break-word;"><div class=3D"">On th=
e other hand, this is an area where some flexibility might be found. Alread=
y, sequence elements in <font face=3D"Courier" class=3D"">std::initial=
izer_list</font> arrays are de-facto not guaranteed uniqueness.</div><=
/div></blockquote><div class=3D"">How is that? All these sequence elements =
are copied into a <font face=3D"courier new, monospace" class=3D"">con=
st</font> array, and [intro.object]/6 guarantees that the element=
s have distinct addresses. If some of them were overlapping, that would not=
give the desired behavior for iteration.</div></div></div></blockquote><di=
v class=3D""><br class=3D""></div>The arrays of two <font face=3D"Courier" =
class=3D"">initializer_list</font> objects may not be distinct, despite [dc=
l.init.list] =C2=A78.5.4/5-6 specifying one array per list object. The elem=
ents in the array are sequential and distinct.<br class=3D""><div class=3D"=
"><br class=3D""></div><div><blockquote type=3D"cite" class=3D""><div class=
=3D"">On 2015=E2=80=9311=E2=80=9303, at 5:15 PM, Columbo <<a href=3D"mai=
lto:r.hl@gmx.net" class=3D"">r.hl@gmx.net</a>> wrote:</div><br class=3D"=
Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" class=3D"">On T=
uesday, November 3, 2015 at 9:07:21 AM UTC, Columbo wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr" class=3D""><div class=3D"">The=
array held is temporary, thus not having static storage duration. Hence th=
e "permitted result" rule is guaranteed to apply, AFAICS. </div></div>=
</blockquote><div class=3D"">Sorry, I have to rectify that first sentence: =
The array does not have static storage duration unless the <font face=3D"co=
urier new, monospace" class=3D"">initializer_list</font> does. So actually,=
in namespace scope, your program should compile.</div></div></div></blockq=
uote><br class=3D""></div><div>To be clear, my example was at function scop=
e, as yours was. The <font face=3D"Courier" class=3D"">initializer_list</fo=
nt> static array storage optimization is not strictly conforming, but the i=
ntent was always to allow it, and all the implementations, to my knowledge,=
do it. That=E2=80=99s why I called it =E2=80=9Cde-facto.=E2=80=9D If you f=
ind this confusing, feel free to submit a defect report.</div><br class=3D"=
"></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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+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/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_5067B9A7-C8A7-4E9C-AD6B-8AC978DE23F2--
.