Topic: Allow the use of references in combination
Author: "D. B." <db0451@gmail.com>
Date: Wed, 3 Aug 2016 17:21:30 +0100
Raw View
--001a1142c656eba6ec05392d3952
Content-Type: text/plain; charset=UTF-8
On Mon, Aug 1, 2016 at 5:46 PM, Matthew Woehlke <mwoehlke.floss@gmail.com>
wrote:
> On 2016-08-01 12:29, D. B. wrote:
> > Union members must have the same address. A reference is an alias to an
> > object and hence has no address of its own The end.
>
> Huh? A reference is a pointer with "sugar". Some of that sugar happens
> to be that it is illegal to take its address, but that doesn't mean it
> doesn't *have* an address.
>
Again, whether or not it has an address in certain contexts is an
implementation detail and hence not relevant.
> Look again at the struct in the OP's message; do you mean to tell me
> that the member 'x' has no address, or (since offsetof(x)==0) that said
> address is different from the address of the struct itself?
>
The struct has an address. The reference doesn't. Any attempt to take the
reference's address, like any other operation on it, takes the address of
the referred object.
> That said, the real problem I see is that a reference usually cannot be
> reseated. A union normally permits the active member to be changed; it's
> unclear how this would work with a reference member. (Also, the OP's
> code is broken because it possibly modifies an inactive member of the
> union. Yes, it might work *in practice*, but it's not conforming.)
>
Yes, that's just another reason that the code is totally broken. And I have
not seen any justification for it, which is bizarre when juxtaposed with
how many far-reaching changes to the language this would require, you'd
think there would be a more pressing rationale than 'I can't just use a
lone pointer because I can't be bothered typing * to dereference it... so I
need to break references to replace this 1 keystroke with a longer variable
name.'
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhEDJgex5Rk%3D%3DcKKrQTj4iYindXkvoqMkznN1p1pZr5LQA%40mail.gmail.com.
--001a1142c656eba6ec05392d3952
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On M=
on, Aug 1, 2016 at 5:46 PM, Matthew Woehlke <span dir=3D"ltr"><<a href=
=3D"mailto:mwoehlke.floss@gmail.com" target=3D"_blank">mwoehlke.floss@gmail=
..com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D=
"">On 2016-08-01 12:29, D. B. wrote:<br>
> Union members must have the same address. A reference is an alias to a=
n<br>
> object and hence has no address of its own The end.<br>
<br>
</span>Huh? A reference is a pointer with "sugar". Some of that s=
ugar happens<br>
to be that it is illegal to take its address, but that doesn't mean it<=
br>
doesn't *have* an address.<br></blockquote><div><br></div><div>Again, w=
hether or not it has an address in certain contexts is an implementation de=
tail and hence not relevant.<br></div><div>=C2=A0<br></div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex">
Look again at the struct in the OP's message; do you mean to tell me<br=
>
that the member 'x' has no address, or (since offsetof(x)=3D=3D0) t=
hat said<br>
address is different from the address of the struct itself?<br></blockquote=
><div><br></div><div>The struct has an address. The reference doesn't. =
Any attempt to take the reference's address, like any other operation o=
n it, takes the address of the referred object.<br></div><div>=C2=A0<br></d=
iv><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex">
That said, the real problem I see is that a reference usually cannot be<br>
reseated. A union normally permits the active member to be changed; it'=
s<br>
unclear how this would work with a reference member. (Also, the OP's<br=
>
code is broken because it possibly modifies an inactive member of the<br>
union. Yes, it might work *in practice*, but it's not conforming.)<br><=
/blockquote><div><br></div><div>Yes, that's just another reason that th=
e code is totally broken. And I have not seen any justification for it, whi=
ch is bizarre when juxtaposed with how many far-reaching changes to the lan=
guage this would require, you'd think there would be a more pressing ra=
tionale than 'I can't just use a lone pointer because I can't b=
e bothered typing * to dereference it... so I need to break references to r=
eplace this 1 keystroke with a longer variable name.'<br></div></div></=
div></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhEDJgex5Rk%3D%3DcKKrQTj4iYindXk=
voqMkznN1p1pZr5LQA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhEDJgex=
5Rk%3D%3DcKKrQTj4iYindXkvoqMkznN1p1pZr5LQA%40mail.gmail.com</a>.<br />
--001a1142c656eba6ec05392d3952--
.
Author: =?UTF-8?Q?Micha=C5=82_Dominiak?= <griwes@griwes.info>
Date: Wed, 03 Aug 2016 16:21:13 +0000
Raw View
--001a11443ae47814ac05392d39f7
Content-Type: text/plain; charset=UTF-8
On Wed, Aug 3, 2016 at 6:16 PM Matthew Woehlke <mwoehlke.floss@gmail.com>
wrote:
> On 2016-08-01 12:29, D. B. wrote:
> > Union members must have the same address. A reference is an alias to an
> > object and hence has no address of its own The end.
>
> Huh? A reference is a pointer with "sugar". Some of that sugar happens
> to be that it is illegal to take its address, but that doesn't mean it
> doesn't *have* an address.
No, a reference type is not an object type, hence it has no storage, and
since it has no storage, it has no address.
And no, a reference is NOT a pointer - it's exactly an alias for another
object; in particular its mere existence can be optimized out by the
compiler.
> Look again at the struct in the OP's message; do you mean to tell me
> that the member 'x' has no address, or (since offsetof(x)==0) that said
> address is different from the address of the struct itself?
>
> That said, the real problem I see is that a reference usually cannot be
> reseated. A union normally permits the active member to be changed; it's
> unclear how this would work with a reference member. (Also, the OP's
> code is broken because it possibly modifies an inactive member of the
> union. Yes, it might work *in practice*, but it's not conforming.)
>
> (This is apparently a recent addition to GCC; 4.9.2 rejects it, though
> 6.1.1 accepts it.)
>
> --
> Matthew
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/nnnudi%24rd%241%40blaine.gmane.org
> .
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPCFJdQX%3DwRJP8XzwsmMheBoSWcARHLMRkSo728c_bv3v7WESg%40mail.gmail.com.
--001a11443ae47814ac05392d39f7
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr">On Wed, Aug 3,=
2016 at 6:16 PM Matthew Woehlke <<a href=3D"mailto:mwoehlke.floss@gmail=
..com">mwoehlke.floss@gmail.com</a>> wrote:<br></div><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex">On 2016-08-01 12:29, D. B. wrote:<br>
> Union members must have the same address. A reference is an alias to a=
n<br>
> object and hence has no address of its own The end.<br>
<br>
Huh? A reference is a pointer with "sugar". Some of that sugar ha=
ppens<br>
to be that it is illegal to take its address, but that doesn't mean it<=
br>
doesn't *have* an address.<span style=3D"line-height:1.5">=C2=A0</span>=
</blockquote><div><br></div><div>No, a reference type is not an object type=
, hence it has no storage, and since it has no storage, it has no address.<=
/div><div><br></div><div>And no, a reference is NOT a pointer - it's ex=
actly an alias for another object; in particular its mere existence can be =
optimized out by the compiler.=C2=A0</div><div>=C2=A0</div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex">
Look again at the struct in the OP's message; do you mean to tell me<br=
>
that the member 'x' has no address, or (since offsetof(x)=3D=3D0) t=
hat said<br>
address is different from the address of the struct itself?<br>
<br>
That said, the real problem I see is that a reference usually cannot be<br>
reseated. A union normally permits the active member to be changed; it'=
s<br>
unclear how this would work with a reference member. (Also, the OP's<br=
>
code is broken because it possibly modifies an inactive member of the<br>
union. Yes, it might work *in practice*, but it's not conforming.)<br>
<br>
(This is apparently a recent addition to GCC; 4.9.2 rejects it, though<br>
6.1.1 accepts it.)<br>
<br>
--<br>
Matthew<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" 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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/nnnudi%24rd%241%40blaine.gmane.org" r=
el=3D"noreferrer" target=3D"_blank">https://groups.google.com/a/isocpp.org/=
d/msgid/std-proposals/nnnudi%24rd%241%40blaine.gmane.org</a>.<br>
</blockquote></div></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAPCFJdQX%3DwRJP8XzwsmMheBoSWcARHLMRk=
So728c_bv3v7WESg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPCFJdQX%3DwRJ=
P8XzwsmMheBoSWcARHLMRkSo728c_bv3v7WESg%40mail.gmail.com</a>.<br />
--001a11443ae47814ac05392d39f7--
.
Author: "D. B." <db0451@gmail.com>
Date: Wed, 3 Aug 2016 17:22:32 +0100
Raw View
--001a114be8fe9e3e3205392d3d49
Content-Type: text/plain; charset=UTF-8
On Wed, Aug 3, 2016 at 5:21 PM, D. B. <db0451@gmail.com> wrote:
> On Mon, Aug 1, 2016 at 5:46 PM, Matthew Woehlke <mwoehlke.floss@gmail.com>
> wrote:
>
>> On 2016-08-01 12:29, D. B. wrote:
>> > Union members must have the same address. A reference is an alias to an
>> > object and hence has no address of its own The end.
>>
>> Huh? A reference is a pointer with "sugar". Some of that sugar happens
>> to be that it is illegal to take its address, but that doesn't mean it
>> doesn't *have* an address.
>>
>
> Again, whether or not it has an address in certain contexts is an
> implementation detail and hence not relevant.
>
I really meant to say 'whether or not it is implemented in terms of a
pointer'. The rest holds.
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhGKo5JBcScm1%2BoVTnc%2Bh-P6TR3Fpi0p2HxJkrJFYh9gOA%40mail.gmail.com.
--001a114be8fe9e3e3205392d3d49
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On W=
ed, Aug 3, 2016 at 5:21 PM, D. B. <span dir=3D"ltr"><<a href=3D"mailto:d=
b0451@gmail.com" target=3D"_blank">db0451@gmail.com</a>></span> wrote:<b=
r><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra=
"><div class=3D"gmail_quote"><span class=3D"">On Mon, Aug 1, 2016 at 5:46 P=
M, Matthew Woehlke <span dir=3D"ltr"><<a href=3D"mailto:mwoehlke.floss@g=
mail.com" target=3D"_blank">mwoehlke.floss@gmail.com</a>></span> wrote:<=
br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><span>On 2016-08-01 12:29, D. B. wrote:<b=
r>
> Union members must have the same address. A reference is an alias to a=
n<br>
> object and hence has no address of its own The end.<br>
<br>
</span>Huh? A reference is a pointer with "sugar". Some of that s=
ugar happens<br>
to be that it is illegal to take its address, but that doesn't mean it<=
br>
doesn't *have* an address.<br></blockquote><div><br></div></span><div>A=
gain, whether or not it has an address in certain contexts is an implementa=
tion detail and hence not relevant.</div></div></div></div></blockquote><di=
v><br></div><div>I really meant to say 'whether or not it is implemente=
d in terms of a pointer'. The rest holds.<br>=C2=A0<br></div></div></di=
v></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhGKo5JBcScm1%2BoVTnc%2Bh-P6TR3F=
pi0p2HxJkrJFYh9gOA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhGKo5JB=
cScm1%2BoVTnc%2Bh-P6TR3Fpi0p2HxJkrJFYh9gOA%40mail.gmail.com</a>.<br />
--001a114be8fe9e3e3205392d3d49--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Wed, 3 Aug 2016 11:21:07 -0500
Raw View
--001a113db3e2e5f7bb05392d3a9d
Content-Type: text/plain; charset=UTF-8
On 1 August 2016 at 11:46, Matthew Woehlke <mwoehlke.floss@gmail.com> wrote:
> On 2016-08-01 12:29, D. B. wrote:
> > Union members must have the same address. A reference is an alias to an
> > object and hence has no address of its own The end.
>
> Huh? A reference is a pointer with "sugar". Some of that sugar happens
> to be that it is illegal to take its address, but that doesn't mean it
> doesn't *have* an address.
>
Given that references are not required to have storage (n4604 [dcl.ref]), I
don't see how you can say a reference is a pointer with sugar.
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> +1-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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BO92peRLcL%2BA%3DhTXC%2BzRQwZpMSOnYSV6Zx2y04vZxzCsw%40mail.gmail.com.
--001a113db3e2e5f7bb05392d3a9d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 1 August 2016 at 11:46, Matthew Woehlke <span dir=3D"lt=
r"><<a href=3D"mailto:mwoehlke.floss@gmail.com" target=3D"_blank">mwoehl=
ke.floss@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra"><div=
class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">On 2=
016-08-01 12:29, D. B. wrote:<br>
> Union members must have the same address. A reference is an alias to a=
n<br>
> object and hence has no address of its own The end.<br>
<br>
</span>Huh? A reference is a pointer with "sugar". Some of that s=
ugar happens<br>
to be that it is illegal to take its address, but that doesn't mean it<=
br>
doesn't *have* an address.<br></blockquote><div><br></div><div>Given th=
at references are not required to have storage (n4604 [dcl.ref]), I don'=
;t see how you can say a reference is a pointer with sugar.</div></div>-- <=
br><div class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div d=
ir=3D"ltr"><div><div dir=3D"ltr"><div>=C2=A0Nevin ":-)" Liber=C2=
=A0 <mailto:<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">=
nevin@eviloverlord.com</a>> =C2=A0+1-847-691-1404</div></div></div></div=
></div>
</div></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2BO92peRLcL%2BA%3DhTXC%2BzRQwZ=
pMSOnYSV6Zx2y04vZxzCsw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGg_6%2B=
O92peRLcL%2BA%3DhTXC%2BzRQwZpMSOnYSV6Zx2y04vZxzCsw%40mail.gmail.com</a>.<br=
/>
--001a113db3e2e5f7bb05392d3a9d--
.