GCC support for extensions from later standards
Nikolas Klauser
nikolasklauser@berlin.de
Tue Aug 8 03:03:05 GMT 2023
On 06.08.23 12:19, Jason Merrill wrote:
> On Wed, Aug 2, 2023 at 12:02 PM Nikolas Klauser
> <nikolasklauser@berlin.de> wrote:
>
> Hi everyone!
>
> I'm working on libc++ and we are currently discussing using
> language extensions from later standards
> (https://discourse.llvm.org/t/rfc-use-language-extensions-from-future-standards-in-libc/71898/4).
> By that I mean things like using `if constexpr` with `-std=c++11`.
> GCC has quite a lot of these kinds of conforming extensions, but
> doesn't document them AFAICT. While discussing using these
> extensions, the question came up what GCCs support policy for
> these is. Aaron was kind enough to answer these questions for us
> on the Clang side. Since I couldn't find anything in the
> documentation, I thought I'd ask here.
>
> So, here are my questions:
>
> Do you expect that these extensions will ever be removed for some
> reason? If yes, what could those reasons be?
>
>
> Potentially, if they don't actually work properly in earlier standard
> modes. I recently noticed that while we allow DMI and =default in
> C++03 mode with a pedwarn, combining them doesn't work.
>
> Some of the extensions are needed by libstdc++ and are therefore well
> tested; these are extremely unlikely to ever be removed. libstdc++
> folks, is there a list of these?
>
> Would you be interested in documenting them?
>
>
> That would be useful, yes.
>
> There is a patch in review to add __has_feature/__has_extension to
> G++, which would seem like a suitable context for this documentation.
>
> Aaron noted that we should ask the Clang folks before using them,
> so they can evaluated whether the extension makes sense, since
> they might not be aware of them, and some might be broken. So I'd
> be interested whether you would also like us to ask whether you
> want to actually support these extensions.
>
>
> Sounds good.
>
> Jason
Thanks for the answers!
There are a few really interesting extensions that I would like to use:
- inline variables
- variable templates
- `if constexpr`
- fold expressions
- conditional explicit
- static operator()
(https://godbolt.org/z/5n9Y4h69n)
Is anybody aware of any problems with these extensions? I'd be happy to
provide a patch to add these extensions to the documentation, but I
couldn't figure out how to build the documentation without building all
of gcc.
Nikolas
More information about the Libstdc++
mailing list