Topic: Need help from C11 implementors/experts about
Author: Daryle Walker <darylew@gmail.com>
Date: Tue, 28 Jan 2014 12:18:58 -0800 (PST)
Raw View
------=_Part_212_29490429.1390940338123
Content-Type: text/plain; charset=UTF-8
When initializing an anonymous union in an aggregate, you have 3 options:
1. "{ *expression-for-first-member* }" Valid when there's at least one
variant member.
2. "*expression-for-first-member*" This uses brace elision; also
requires at least one variant.
3. "{ }" Valid when the first member can be defaulted, or the anonymous
union is empty.
These forms can be used for named union members and named non-union class
members too. (For non-unions, any non-static data members after the first
have to be default-constructible.) The rules for aggregate initialization
(section 8.5.1) says all non-static data members have terms except for
anonymous bit fields. I reviewed a copy of the final C11 draft; the rules
of initialization (section 6.9, I think) says that anonymous structs and
unions aren't considered. What does that mean?
Unlike the rule for C++ anonymous bit fields, the rule for C anonymous
structs/unions does not have an example. (The C++ standard puts its
examples next to the matching paragraph or sentence. The C standard puts
all the examples for a section after all the prose.) If the rule means that
anonymous structs/unions or their members can't have an initialization
term, then how is data within them initialized? Are designated initializers
the only way to initialize data inside anonymous structs/unions in C11?
What about named members declared after an anonymous struct/union; is the
anonymous member a cut-off (so they need designators too), or do we skip
them to the next named member?
I'm asking because I'm writing a anonymous class type proposal for C++(17),
and I'm worried that I just found a point of incompatibility here.
Daryle W.
--
---
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_212_29490429.1390940338123
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">When initializing an anonymous union in an aggregate, you =
have 3 options:<div><ol><li><span style=3D"line-height: normal;">"<font fac=
e=3D"courier new, monospace">{ <i>expression-for-first-member</i> }</font>"=
Valid when there's at least one variant member.</span></li><li><span style=
=3D"line-height: normal;">"<font face=3D"courier new, monospace"><i>express=
ion-for-first-member</i></font>" This uses brace elision; also requires at =
least one variant.</span></li><li><span style=3D"line-height: normal;">"<fo=
nt face=3D"courier new, monospace">{ }</font>" Valid when the first member =
can be defaulted, or the anonymous union is empty.</span></li></ol>These fo=
rms can be used for named union members and named non-union class members t=
oo. (For non-unions, any non-static data members after the first have=
to be default-constructible.) The rules for aggregate initialization (sect=
ion 8.5.1) says all non-static data members have terms except for anonymous=
bit fields. I reviewed a copy of the final C11 draft; the rules of initial=
ization (section 6.9, I think) says that anonymous structs and unions aren'=
t considered. What does that mean?</div><div><br></div><div>Unlike the rule=
for C++ anonymous bit fields, the rule for C anonymous structs/unions does=
not have an example. (The C++ standard puts its examples next to the match=
ing paragraph or sentence. The C standard puts all the examples for a secti=
on after all the prose.) If the rule means that anonymous structs/unions or=
their members can't have an initialization term, then how is data within t=
hem initialized? Are designated initializers the only way to initialize dat=
a inside anonymous structs/unions in C11? What about named members declared=
after an anonymous struct/union; is the anonymous member a cut-off (so the=
y need designators too), or do we skip them to the next named member?</div>=
<div><br></div><div>I'm asking because I'm writing a anonymous class type p=
roposal for C++(17), and I'm worried that I just found a point of incompati=
bility here.</div><div><br></div><div>Daryle W.</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 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_212_29490429.1390940338123--
.
Author: Daryle Walker <darylew@gmail.com>
Date: Tue, 28 Jan 2014 22:28:50 -0500
Raw View
--047d7b5d5610225e3c04f1138ae5
Content-Type: text/plain; charset=ISO-8859-1
The applicable part in the C 2011 final draft (n1570.pdf) is actually
section 6.7.9 (Initialization), paragraph 9.
On Tue, Jan 28, 2014 at 3:18 PM, Daryle Walker <darylew@gmail.com> wrote:
> When initializing an anonymous union in an aggregate, you have 3 options:
>
> 1. "{ *expression-for-first-member* }" Valid when there's at least one
> variant member.
> 2. "*expression-for-first-member*" This uses brace elision; also
> requires at least one variant.
> 3. "{ }" Valid when the first member can be defaulted, or the
> anonymous union is empty.
>
> These forms can be used for named union members and named non-union class
> members too. (For non-unions, any non-static data members after the first
> have to be default-constructible.) The rules for aggregate initialization
> (section 8.5.1) says all non-static data members have terms except for
> anonymous bit fields. I reviewed a copy of the final C11 draft; the rules
> of initialization (section 6.9, I think) says that anonymous structs and
> unions aren't considered. What does that mean?
>
> Unlike the rule for C++ anonymous bit fields, the rule for C anonymous
> structs/unions does not have an example. (The C++ standard puts its
> examples next to the matching paragraph or sentence. The C standard puts
> all the examples for a section after all the prose.) If the rule means that
> anonymous structs/unions or their members can't have an initialization
> term, then how is data within them initialized? Are designated initializers
> the only way to initialize data inside anonymous structs/unions in C11?
> What about named members declared after an anonymous struct/union; is the
> anonymous member a cut-off (so they need designators too), or do we skip
> them to the next named member?
>
> I'm asking because I'm writing a anonymous class type proposal for
> C++(17), and I'm worried that I just found a point of incompatibility here.
>
> Daryle W.
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/oG8Cn-UfgDw/unsubscribe
> .
> To unsubscribe from this group and all its topics, 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/.
>
--
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT gmail DOT com
--
---
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/.
--047d7b5d5610225e3c04f1138ae5
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The applicable part in the C 2011 final draft (n1570.pdf) =
is actually section 6.7.9 (Initialization), paragraph 9.<br></div><div clas=
s=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Tue, Jan 28, 2014 a=
t 3:18 PM, Daryle Walker <span dir=3D"ltr"><<a href=3D"mailto:darylew@gm=
ail.com" target=3D"_blank">darylew@gmail.com</a>></span> wrote:<br>
<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">When initializing an anonym=
ous union in an aggregate, you have 3 options:<div><ol><li><span style=3D"l=
ine-height:normal">"<font face=3D"courier new, monospace">{ <i>express=
ion-for-first-member</i> }</font>" Valid when there's at least one=
variant member.</span></li>
<li><span style=3D"line-height:normal">"<font face=3D"courier new, mon=
ospace"><i>expression-for-first-member</i></font>" This uses brace eli=
sion; also requires at least one variant.</span></li><li><span style=3D"lin=
e-height:normal">"<font face=3D"courier new, monospace">{ }</font>&quo=
t; Valid when the first member can be defaulted, or the anonymous union is =
empty.</span></li>
</ol>These forms can be used for named union members and named non-union cl=
ass members too. =A0(For non-unions, any non-static data members after the =
first have to be default-constructible.) The rules for aggregate initializa=
tion (section 8.5.1) says all non-static data members have terms except for=
anonymous bit fields. I reviewed a copy of the final C11 draft; the rules =
of initialization (section 6.9, I think) says that anonymous structs and un=
ions aren't considered. What does that mean?</div>
<div><br></div><div>Unlike the rule for C++ anonymous bit fields, the rule =
for C anonymous structs/unions does not have an example. (The C++ standard =
puts its examples next to the matching paragraph or sentence. The C standar=
d puts all the examples for a section after all the prose.) If the rule mea=
ns that anonymous structs/unions or their members can't have an initial=
ization term, then how is data within them initialized? Are designated init=
ializers the only way to initialize data inside anonymous structs/unions in=
C11? What about named members declared after an anonymous struct/union; is=
the anonymous member a cut-off (so they need designators too), or do we sk=
ip them to the next named member?</div>
<div><br></div><div>I'm asking because I'm writing a anonymous clas=
s type proposal for C++(17), and I'm worried that I just found a point =
of incompatibility here.</div><div><br></div><div>Daryle W.</div><span clas=
s=3D"HOEnZb"><font color=3D"#888888"><div>
<br></div></font></span></div><span class=3D"HOEnZb"><font color=3D"#888888=
">
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/oG8Cn-UfgDw/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/oG8Cn-UfgDw=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D"_blank">std-pr=
oposals+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>
</font></span></blockquote></div><br><br clear=3D"all"><br>-- <br>Daryle Wa=
lker<br>Mac, Internet, and Video Game Junkie<br>darylew AT gmail DOT com
</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 />
--047d7b5d5610225e3c04f1138ae5--
.
Author: Daryle Walker <darylew@gmail.com>
Date: Tue, 28 Jan 2014 23:19:41 -0500
Raw View
--f46d044288c0f7b61d04f1143fb5
Content-Type: text/plain; charset=ISO-8859-1
I was going to ask about this on StackOverflow, since I didn't see a
relevant query, but I saw one
<http://stackoverflow.com/q/5063548/1010226>in the related section
once I started to type in a new query. It seems that
the anonymous composite is not part of its outer type's aggregate
initialization but the composite's enclosed names are moved to the outer
type for purposes of initialization. Starting an list-initialization where
an anonymous composite would start just initializes the first member with a
gratuitous set of braces. The post doesn't cover what happens with
anonymous unions; if an initializer term following the one for a union goes
to the next member following the union.
I still don't know what this means for bringing C11's anonymous composite
feature to C++, and if the two languages' approaches are incompatible.
On Tue, Jan 28, 2014 at 10:28 PM, Daryle Walker <darylew@gmail.com> wrote:
> The applicable part in the C 2011 final draft (n1570.pdf) is actually
> section 6.7.9 (Initialization), paragraph 9.
>
>
> On Tue, Jan 28, 2014 at 3:18 PM, Daryle Walker <darylew@gmail.com> wrote:
>
>> When initializing an anonymous union in an aggregate, you have 3 options:
>>
>> 1. "{ *expression-for-first-member* }" Valid when there's at least
>> one variant member.
>> 2. "*expression-for-first-member*" This uses brace elision; also
>> requires at least one variant.
>> 3. "{ }" Valid when the first member can be defaulted, or the
>> anonymous union is empty.
>>
>> These forms can be used for named union members and named non-union class
>> members too. (For non-unions, any non-static data members after the first
>> have to be default-constructible.) The rules for aggregate initialization
>> (section 8.5.1) says all non-static data members have terms except for
>> anonymous bit fields. I reviewed a copy of the final C11 draft; the rules
>> of initialization (section 6.9, I think) says that anonymous structs and
>> unions aren't considered. What does that mean?
>>
>> Unlike the rule for C++ anonymous bit fields, the rule for C anonymous
>> structs/unions does not have an example. (The C++ standard puts its
>> examples next to the matching paragraph or sentence. The C standard puts
>> all the examples for a section after all the prose.) If the rule means that
>> anonymous structs/unions or their members can't have an initialization
>> term, then how is data within them initialized? Are designated initializers
>> the only way to initialize data inside anonymous structs/unions in C11?
>> What about named members declared after an anonymous struct/union; is the
>> anonymous member a cut-off (so they need designators too), or do we skip
>> them to the next named member?
>>
>> I'm asking because I'm writing a anonymous class type proposal for
>> C++(17), and I'm worried that I just found a point of incompatibility here.
>>
>> Daryle W.
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/oG8Cn-UfgDw/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/.
>>
>
>
>
> --
> Daryle Walker
> Mac, Internet, and Video Game Junkie
> darylew AT gmail DOT com
>
--
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT gmail DOT com
--
---
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/.
--f46d044288c0f7b61d04f1143fb5
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I was going to ask about this on StackOverflow, since=
I didn't see a relevant query, but I saw <a href=3D"http://stackoverfl=
ow.com/q/5063548/1010226">one</a> in the related section once I started to =
type in a new query. It seems that the anonymous composite is not part of i=
ts outer type's aggregate initialization but the composite's enclos=
ed names are moved to the outer type for purposes of initialization. Starti=
ng an list-initialization where an anonymous composite would start just ini=
tializes the first member with a gratuitous set of braces. The post doesn&#=
39;t cover what happens with anonymous unions; if an initializer term follo=
wing the one for a union goes to the next member following the union.<br>
<br></div>I still don't know what this means for bringing C11's ano=
nymous composite feature to C++, and if the two languages' approaches a=
re incompatible.<br><div><br></div></div><div class=3D"gmail_extra"><br><br=
>
<div class=3D"gmail_quote">On Tue, Jan 28, 2014 at 10:28 PM, Daryle Walker =
<span dir=3D"ltr"><<a href=3D"mailto:darylew@gmail.com" target=3D"_blank=
">darylew@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
>
<div dir=3D"ltr">The applicable part in the C 2011 final draft (n1570.pdf) =
is actually section 6.7.9 (Initialization), paragraph 9.<br></div><div clas=
s=3D"gmail_extra"><div><div class=3D"h5"><br><br><div class=3D"gmail_quote"=
>On Tue, Jan 28, 2014 at 3:18 PM, Daryle Walker <span dir=3D"ltr"><<a hr=
ef=3D"mailto:darylew@gmail.com" target=3D"_blank">darylew@gmail.com</a>>=
</span> wrote:<br>
<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">When initializing an anonym=
ous union in an aggregate, you have 3 options:<div><ol><li><span style=3D"l=
ine-height:normal">"<font face=3D"courier new, monospace">{ <i>express=
ion-for-first-member</i> }</font>" Valid when there's at least one=
variant member.</span></li>
<li><span style=3D"line-height:normal">"<font face=3D"courier new, mon=
ospace"><i>expression-for-first-member</i></font>" This uses brace eli=
sion; also requires at least one variant.</span></li><li><span style=3D"lin=
e-height:normal">"<font face=3D"courier new, monospace">{ }</font>&quo=
t; Valid when the first member can be defaulted, or the anonymous union is =
empty.</span></li>
</ol>These forms can be used for named union members and named non-union cl=
ass members too. =A0(For non-unions, any non-static data members after the =
first have to be default-constructible.) The rules for aggregate initializa=
tion (section 8.5.1) says all non-static data members have terms except for=
anonymous bit fields. I reviewed a copy of the final C11 draft; the rules =
of initialization (section 6.9, I think) says that anonymous structs and un=
ions aren't considered. What does that mean?</div>
<div><br></div><div>Unlike the rule for C++ anonymous bit fields, the rule =
for C anonymous structs/unions does not have an example. (The C++ standard =
puts its examples next to the matching paragraph or sentence. The C standar=
d puts all the examples for a section after all the prose.) If the rule mea=
ns that anonymous structs/unions or their members can't have an initial=
ization term, then how is data within them initialized? Are designated init=
ializers the only way to initialize data inside anonymous structs/unions in=
C11? What about named members declared after an anonymous struct/union; is=
the anonymous member a cut-off (so they need designators too), or do we sk=
ip them to the next named member?</div>
<div><br></div><div>I'm asking because I'm writing a anonymous clas=
s type proposal for C++(17), and I'm worried that I just found a point =
of incompatibility here.</div><div><br></div><div>Daryle W.</div><span><fon=
t color=3D"#888888"><div>
<br></div></font></span></div><span><font color=3D"#888888">
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/oG8Cn-UfgDw/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/oG8Cn-UfgDw=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D"_blank">std-pr=
oposals+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>
</font></span></blockquote></div><br><br clear=3D"all"><br></div></div><spa=
n class=3D"HOEnZb"><font color=3D"#888888">-- <br>Daryle Walker<br>Mac, Int=
ernet, and Video Game Junkie<br>darylew AT gmail DOT com
</font></span></div>
</blockquote></div><br><br clear=3D"all"><br>-- <br>Daryle Walker<br>Mac, I=
nternet, and Video Game Junkie<br>darylew AT gmail DOT com
</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 />
--f46d044288c0f7b61d04f1143fb5--
.