On Wed, 21 Aug 2024 at 10:03, Andrew Pinski <pins...@gmail.com> wrote:
>
> On Wed, Aug 21, 2024 at 1:56 AM Jonathan Wakely <jwak...@redhat.com> wrote:
> >
> > Tested x86_64-linux. Pushed to trunk.
> >
> > Probably worth backporting too. It could potentially cause new errors
> > for people using arrays in std::variant, but that's forbidden by the
> > standard.
>
> It might be worth mentioning in porting_to guide just in case. You
> never know since we have gotten bug reports about broken code that was
> also rejected by clang/MSVC due to a change in GCC.

Let's wait and see if it breaks anything when distros start building
with the change. I don't expect any real world code to break, and if
I'm right then there's no point documenting the change.

For the backports maybe it makes sense to do it conditionally:

#ifdef __STRICT_ANSI__
      static_assert(((std::is_object_v<_Types> && !is_array_v<_Types>) && ...),
            "variant alternatives must be non-array object types");
#else
      static_assert((std::is_object_v<_Types> && ...),
            "variant alternatives must be object types");
#endif

If you're asking for strict conformance, you shouldn't be using arrays
in std::variant. This would avoid changing behaviour on release
branches for non-strict modes.

Reply via email to