libstdc++: add a constexpr macro for C++26
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
pending
|
Build started
|
Commit Message
Hello,
The attached patch adds _GLIBCXX26_CONSTEXPR, in preparation for adding
`constexpr` on some functions starting in C++26.
Thanks,
--
Giuseppe D'Angelo
Comments
On Wed, Jan 08, 2025 at 11:44:50AM +0100, Giuseppe D'Angelo wrote:
> The attached patch adds _GLIBCXX26_CONSTEXPR, in preparation for adding
> `constexpr` on some functions starting in C++26.
>
> Thanks,
> --
> Giuseppe D'Angelo
> From 61115549376a29558eb7753f525daf671c6da929 Mon Sep 17 00:00:00 2001
> From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
> Date: Wed, 1 Jan 2025 12:12:29 +0100
> Subject: [PATCH] libstdc++: add a constexpr macro for C++26
>
> Following the precedent of _GLIBCXX20_CONSTEXPR.
> It will be used to decorate some functions which have been made
> constexpr in C++26 (for instance P2562R1, and maybe P3508R0, P3369R0,
> ...).
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/c++config: Added the
> _GLIBCXX26_CONSTEXPR macro.
>
> Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
> ---
> libstdc++-v3/include/bits/c++config | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
> index a5001d0a0b0..7dc07a77c84 100644
> --- a/libstdc++-v3/include/bits/c++config
> +++ b/libstdc++-v3/include/bits/c++config
> @@ -222,6 +222,14 @@
> # endif
> #endif
>
> +#ifndef _GLIBCXX26_CONSTEXPR
> +# if __cplusplus >= 202303L
Shouldn't that be 202400L instead? I mean that is what
-std=c++26/-std=gnu++26 predefines and has been historically what we've been
using for next version.
I think clang++ also predefines 202400L.
Jakub
On 08/01/2025 11:49, Jakub Jelinek wrote:
>>
>> +#ifndef _GLIBCXX26_CONSTEXPR
>> +# if __cplusplus >= 202303L
> Shouldn't that be 202400L instead? I mean that is what
> -std=c++26/-std=gnu++26 predefines and has been historically what we've been
> using for next version.
> I think clang++ also predefines 202400L.
Fair enough, GCC documentation simply says "an unspecified value
strictly larger than 202302L for the experimental languages enabled by
-std=c++26 and -std=gnu++26", so I picked ... a value larger than
202302L. I can certainly change it for the historical reason, just let
me know.
--
Giuseppe D'Angelo
On Wed, Jan 08, 2025 at 11:57:32AM +0100, Giuseppe D'Angelo wrote:
> On 08/01/2025 11:49, Jakub Jelinek wrote:
> > > +#ifndef _GLIBCXX26_CONSTEXPR
> > > +# if __cplusplus >= 202303L
> > Shouldn't that be 202400L instead? I mean that is what
> > -std=c++26/-std=gnu++26 predefines and has been historically what we've been
> > using for next version.
> > I think clang++ also predefines 202400L.
>
> Fair enough, GCC documentation simply says "an unspecified value strictly
> larger than 202302L for the experimental languages enabled by -std=c++26 and
> -std=gnu++26", so I picked ... a value larger than 202302L. I can certainly
> change it for the historical reason, just let me know.
This is libstdc++ patch, so I'll defer to Jonathan, both the decision and
review of the patch.
Jakub
On Wed, 8 Jan 2025 at 11:00, Jakub Jelinek wrote:
>
> On Wed, Jan 08, 2025 at 11:57:32AM +0100, Giuseppe D'Angelo wrote:
> > On 08/01/2025 11:49, Jakub Jelinek wrote:
> > > > +#ifndef _GLIBCXX26_CONSTEXPR
> > > > +# if __cplusplus >= 202303L
> > > Shouldn't that be 202400L instead? I mean that is what
> > > -std=c++26/-std=gnu++26 predefines and has been historically what we've been
> > > using for next version.
> > > I think clang++ also predefines 202400L.
> >
> > Fair enough, GCC documentation simply says "an unspecified value strictly
> > larger than 202302L for the experimental languages enabled by -std=c++26 and
> > -std=gnu++26", so I picked ... a value larger than 202302L. I can certainly
> > change it for the historical reason, just let me know.
>
> This is libstdc++ patch, so I'll defer to Jonathan, both the decision and
> review of the patch.
I agree with using 202400L, for consistency with the actual defined
value, and because at a quick glance it's unclear whether 202303 is
the value for C++23 or not. You have to know that 202302 is the real
value to identify that this is "something later than C++23" whereas
202400 is more obvious.
Hi,
On 08/01/2025 13:06, Jonathan Wakely wrote:
> I agree with using 202400L, for consistency with the actual defined
> value, and because at a quick glance it's unclear whether 202303 is
> the value for C++23 or not. You have to know that 202302 is the real
> value to identify that this is "something later than C++23" whereas
> 202400 is more obvious.
Good point! New patch attached.
Thanks,
--
Giuseppe D'Angelo
From 61115549376a29558eb7753f525daf671c6da929 Mon Sep 17 00:00:00 2001
From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Date: Wed, 1 Jan 2025 12:12:29 +0100
Subject: [PATCH] libstdc++: add a constexpr macro for C++26
Following the precedent of _GLIBCXX20_CONSTEXPR.
It will be used to decorate some functions which have been made
constexpr in C++26 (for instance P2562R1, and maybe P3508R0, P3369R0,
...).
libstdc++-v3/ChangeLog:
* include/bits/c++config: Added the
_GLIBCXX26_CONSTEXPR macro.
Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
---
libstdc++-v3/include/bits/c++config | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -222,6 +222,14 @@
# endif
#endif
+#ifndef _GLIBCXX26_CONSTEXPR
+# if __cplusplus >= 202303L
+# define _GLIBCXX26_CONSTEXPR constexpr
+# else
+# define _GLIBCXX26_CONSTEXPR
+# endif
+#endif
+
#ifndef _GLIBCXX17_INLINE
# if __cplusplus >= 201703L
# define _GLIBCXX17_INLINE inline
--
2.34.1