vec: Fix bootstrap on i686-linux, 32-bit darwin and AIX
authorJakub Jelinek <jakub@redhat.com>
Fri, 14 Aug 2020 07:29:47 +0000 (09:29 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 14 Aug 2020 07:29:47 +0000 (09:29 +0200)
commit22dc89f8073cd0126efa72aa3ab88e80c78d45e3
treeec8d221fabb79c0c923d80d87a368b3135f4d35b
parent5afd18820f4b72e1baa036db4d81d63cdf07ad68
vec: Fix bootstrap on i686-linux, 32-bit darwin and AIX

As mentioned earlier, embedded_size is broken on vecs of long long, double
etc. on some platforms, which breaks bootstrap.
E.g. on i686-linux, the problem is mostly with older GCC versions being used
as stage1 compiler (GCC 4.8 to 7.* in particular), because alignas (long long)
makes U 64-bit aligned, while when long long m_vecdata[1]; is in vec, it is
only 32-bit aligned.  We've tried various ways and the following one seems
to work, use the old way (offsetof (vec, m_vecdata)) for non-class types
as well as standard layout class types, i.e. whenever offsetof is guaranteed
to work, and for others use the new day (in that case we don't run into
problems with long long or other scalar types and for the structure layout
there is just a struct with a given alignment.

2020-08-14  Jakub Jelinek  <jakub@redhat.com>
    Jonathan Wakely  <jwakely@redhat.com>

* system.h: Include type_traits.
* vec.h (vec<T, A, vl_embed>::embedded_size): Use offsetof and asserts
on vec_stdlayout, which is conditionally a vec (for standard layout T)
and otherwise vec_embedded.

Co-Authored-By: Jonathan Wakely <jwakely@redhat.com>
gcc/system.h
gcc/vec.h