std:vec for classes with constructor?

Jakub Jelinek jakub@redhat.com
Fri Aug 7 18:33:26 GMT 2020


On Fri, Aug 07, 2020 at 08:04:57PM +0200, Aldy Hernandez wrote:
> --- a/gcc/ipa-fnsummary.c
> +++ b/gcc/ipa-fnsummary.c
> @@ -82,7 +82,6 @@ along with GCC; see the file COPYING3.  If not see
>  #include "gimplify.h"
>  #include "stringpool.h"
>  #include "attribs.h"
> -#include <vector>
>  #include "tree-into-ssa.h"

This part won't apply (Gerald has changed it to #define INCLUDE_VECTOR
earlier I think).

> --- a/gcc/vec.h
> +++ b/gcc/vec.h
> @@ -1281,7 +1281,10 @@ template<typename T, typename A>
>  inline size_t
>  vec<T, A, vl_embed>::embedded_size (unsigned alloc)
>  {
> -  typedef vec<T, A, vl_embed> vec_embedded;
> +  struct alignas (T) U { char data[sizeof (T)]; };
> +  typedef vec<U, A, vl_embed> vec_embedded;
> +  static_assert(sizeof(vec_embedded) == sizeof(vec), "");
> +  static_assert(alignof(vec_embedded) == alignof(vec), "");

s/(/ (/g on the above two lines please (GCC vs. libstdc++ coding
style differences).

I think it would be nice to see e.g. in -fdump-tree-gimple dump
on ipa-fnsummary.c what value_range ctors does it call for the auto_vec and
if that is what we want, other than that LGTM.

	Jakub



More information about the Gcc-patches mailing list