https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97474
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #10) > I think the place in the C++ FE that adds restrict here is: > tree > type_passed_as (tree type) > { > /* Pass classes with copy ctors by invisible reference. */ > if (TREE_ADDRESSABLE (type)) > { > type = build_reference_type (type); > /* There are no other pointers to this temporary. */ > type = cp_build_qualified_type (type, TYPE_QUAL_RESTRICT); > } > > So, the options are either not to do it for types that contain any > pointers/references among its members, or do some extra analysis as to > whether even if it contains some pointers/references if those are guaranteed > not to point to anything within the structure (e.g. because of TBAA rules), > or using that analysis decide if it can use normal restrict or needs to use > a weaker restrict, etc. E.g. the vtable pointer is guaranteed not to point into the structure, so that one can be special cased in the checking.