On Thu, 16 Sep 2021, Jakub Jelinek wrote: > On Thu, Sep 16, 2021 at 11:48:49AM +0200, Richard Biener via Gcc-patches > wrote: > > 2021-09-16 Richard Biener <rguent...@suse.de> > > > > PR middle-end/102360 > > * internal-fn.c (expand_DEFERRED_INIT): Make pattern-init > > of non-memory more robust. > > > > * g++.dg/pr102360.C: New testcase. > > + if (can_native_interpret_type_p (var_type)) > > + init = native_interpret_expr (var_type, buf, total_bytes); > > + else > > + { > > + tree itype = build_nonstandard_integer_type (total_bytes * 8, 1); > > Shouldn't that 8 be BITS_PER_UNIT ? > I know we have tons of problems with BITS_PER_UNIT is not 8, but adding > further ones is unnecessary.
Well, a byte is 8 bits and we do unsigned HOST_WIDE_INT total_bytes = tree_to_uhwi (TYPE_SIZE_UNIT (var_type)); if (init_type == AUTO_INIT_PATTERN) { unsigned char *buf = (unsigned char *) xmalloc (total_bytes); memset (buf, INIT_PATTERN_VALUE, total_bytes); and thus mix host and target here. I suppose it should be instead unsigned HOST_WIDE_INT total_bytes = tree_to_uhwi (TYPE_SIZE (var_type)) / (BITS_PER_UNIT / 8); or so... in this light * 8 for the build_nonstandard_integer_type use is correct, no? If total_bytes is really _bytes_. Richard.