Topic: P0386R0 (inline variables): non-inline constexpr declaration
Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 15 Jul 2016 21:56:50 -0700
Raw View
The paper ends with this proposed addition to the standard:
> For compatibility with prior C++ International Standards, a constexpr sta=
tic
> data member may be redundantly redeclared outside the class with no
> initializer. This usage is deprecated. [ Example:
>=20
> struct A {
> static constexpr int n =3D 5; // definition (declaration in C++ 2014)
> };
> const int A::n; // redundant declaration (definition in C++ 2014)
>=20
> =E2=80=94 end example ]
Here's the problem: changing the meaning of the above may be an ABI break.
The way the current code works, if you form a pointer to A::n, including wh=
en=20
passing it by reference, the compiler expects the out-of-class declaration=
=20
like the above shows to exist somewhere.
Making that redundant declaration unnecessary implies that the inline=20
declaration must be emitted as a vague symbol in every translation unit tha=
t=20
it is used in. There may be ABIs where vague symbols are not necessarily we=
ak=20
and may not exist in combination with the symbol that the current code with=
C+
+14 produces.
My recommentation is for the committee to wait for compilers to execute a=
=20
survey of their ABIs to determine whether this change in the language would=
=20
imply a binary compatibility break for code that has constexpr variables in=
=20
headers.
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/734397446.UKLzu5glU2%40tjmaciei-mobl1.
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Sat, 16 Jul 2016 13:41:05 -0700
Raw View
--94eb2c0837a60718660537c6c1cc
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On 15 Jul 2016 9:56 p.m., "Thiago Macieira" <thiago@macieira.org> wrote:
>
> The paper ends with this proposed addition to the standard:
>
> > For compatibility with prior C++ International Standards, a constexpr
static
> > data member may be redundantly redeclared outside the class with no
> > initializer. This usage is deprecated. [ Example:
> >
> > struct A {
> > static constexpr int n =3D 5; // definition (declaration in C++ 2014)
> > };
> > const int A::n; // redundant declaration (definition in C++ 2014)
> >
> > =E2=80=94 end example ]
>
> Here's the problem: changing the meaning of the above may be an ABI break=
..
>
> The way the current code works, if you form a pointer to A::n, including
when
> passing it by reference, the compiler expects the out-of-class declaratio=
n
> like the above shows to exist somewhere.
>
> Making that redundant declaration unnecessary implies that the inline
> declaration must be emitted as a vague symbol in every translation unit
that
> it is used in. There may be ABIs where vague symbols are not necessarily
weak
> and may not exist in combination with the symbol that the current code
with C+
> +14 produces.
>
> My recommentation is for the committee to wait for compilers to execute a
> survey of their ABIs to determine whether this change in the language
would
> imply a binary compatibility break for code that has constexpr variables
in
> headers.
This survey was in fact already performed, between the Kona meeting when
this was first suggested and the Oulu meeting when it was formally
proposed. The only platform on which a problem was discovered was Mac OS 9
and before, on which there was no interest in implementing this feature.
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel Open Source Technology Center
>
> --
> 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/734397446.UKLz=
u5glU2%40tjmaciei-mobl1
..
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAOfiQq%3Dugmc%2B6-eGk14Kq%3Do2GaxxGNn9DV%2B%3DB=
bF0Lw-%2B5DANZA%40mail.gmail.com.
--94eb2c0837a60718660537c6c1cc
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<p dir=3D"ltr">On 15 Jul 2016 9:56 p.m., "Thiago Macieira" <<a=
href=3D"mailto:thiago@macieira.org">thiago@macieira.org</a>> wrote:<br>
><br>
> The paper ends with this proposed addition to the standard:<br>
><br>
> > For compatibility with prior C++ International Standards, a const=
expr static<br>
> > data member may be redundantly redeclared outside the class with =
no<br>
> > initializer. This usage is deprecated. [ Example:<br>
> ><br>
> > struct A {<br>
> > static constexpr int n =3D 5; // definition (declaration in C++ 2=
014)<br>
> > };<br>
> > const int A::n; // redundant declaration (definition in C++ 2014)=
<br>
> ><br>
> > =E2=80=94 end example ]<br>
><br>
> Here's the problem: changing the meaning of the above may be an AB=
I break.<br>
><br>
> The way the current code works, if you form a pointer to A::n, includi=
ng when<br>
> passing it by reference, the compiler expects the out-of-class declara=
tion<br>
> like the above shows to exist somewhere.<br>
><br>
> Making that redundant declaration unnecessary implies that the inline<=
br>
> declaration must be emitted as a vague symbol in every translation uni=
t that<br>
> it is used in. There may be ABIs where vague symbols are not necessari=
ly weak<br>
> and may not exist in combination with the symbol that the current code=
with C+<br>
> +14 produces.<br>
><br>
> My recommentation is for the committee to wait for compilers to execut=
e a<br>
> survey of their ABIs to determine whether this change in the language =
would<br>
> imply a binary compatibility break for code that has constexpr variabl=
es in<br>
> headers.</p>
<p dir=3D"ltr">This survey was in fact already performed, between the Kona =
meeting when this was first suggested and the Oulu meeting when it was form=
ally proposed. The only platform on which a problem was discovered was Mac =
OS 9 and before, on which there was no interest in implementing this featur=
e.</p>
<p dir=3D"ltr">> --<br>
> Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info">macieir=
a.info</a> - thiago (AT) <a href=3D"http://kde.org">kde.org</a><br>
> =C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center<=
br>
><br>
> --<br>
> You received this message because you are subscribed to the Google Gro=
ups "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%2Bunsubscribe@isocpp.org">std-=
proposals+unsubscribe@isocpp.org</a>.<br>
> To post to this group, send email to <a href=3D"mailto:std-proposals@i=
socpp.org">std-proposals@isocpp.org</a>.<br>
> To view this discussion on the web visit <a href=3D"https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/734397446.UKLzu5glU2%40tjmaciei-=
mobl1">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7343974=
46.UKLzu5glU2%40tjmaciei-mobl1</a>.<br></p>
<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/CAOfiQq%3Dugmc%2B6-eGk14Kq%3Do2GaxxGN=
n9DV%2B%3DBbF0Lw-%2B5DANZA%40mail.gmail.com?utm_medium=3Demail&utm_source=
=3Dfooter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAO=
fiQq%3Dugmc%2B6-eGk14Kq%3Do2GaxxGNn9DV%2B%3DBbF0Lw-%2B5DANZA%40mail.gmail.c=
om</a>.<br />
--94eb2c0837a60718660537c6c1cc--
.