Date: Thu, 17 Aug 2023 21:37:56 +0100
On Thu, 2023-08-17 at 21:21 +0100, Frederick Virchanza Gotham via Std-
Proposals wrote:
> On Thu, Aug 17, 2023 at 9:08 PM Lénárd Szolnoki wrote:
> >
> > foo(a, pretend_is_std_array(a.arr)); // breaking the aliasing
> > assumption here
>
>
> I'll get to the point here:
>
> How about we explicitly write in the C++26 Standard that T[len] and
> array<T,len> are ABI-compatible, and also provide two functions:
>
> stdarray_to_array
> array_to_stdarray
>
> , both of which return a reference to an object that doesn't
> malfunction where you have anti-aliasing optimisations.
This doesn't help code compiled with earlier standards and compilers
that already made use of the aliasing assumption. So this is
potentially ABI break. It also complicates the object model needlessly,
although I assume it's not much worse than std::complex.
This lacks motivation. The main problem seems to be interfaces that
take reference to std::array or C array instead of taking a std::span
by value. Just use `std::span`, it won't even change to calling
convention with static extent and can accept a wide range of contiguous
containers.
Cheers,
Lénárd
Proposals wrote:
> On Thu, Aug 17, 2023 at 9:08 PM Lénárd Szolnoki wrote:
> >
> > foo(a, pretend_is_std_array(a.arr)); // breaking the aliasing
> > assumption here
>
>
> I'll get to the point here:
>
> How about we explicitly write in the C++26 Standard that T[len] and
> array<T,len> are ABI-compatible, and also provide two functions:
>
> stdarray_to_array
> array_to_stdarray
>
> , both of which return a reference to an object that doesn't
> malfunction where you have anti-aliasing optimisations.
This doesn't help code compiled with earlier standards and compilers
that already made use of the aliasing assumption. So this is
potentially ABI break. It also complicates the object model needlessly,
although I assume it's not much worse than std::complex.
This lacks motivation. The main problem seems to be interfaces that
take reference to std::array or C array instead of taking a std::span
by value. Just use `std::span`, it won't even change to calling
convention with static extent and can accept a wide range of contiguous
containers.
Cheers,
Lénárd
Received on 2023-08-17 20:38:01