Hello Bernd, Bernd Schmidt <bschm...@redhat.com> writes:
> I came across what I think is a bug in cxx_fundamental_alignment_p. > > User alignments are specified in units of bytes. This is documented, > and we can also see the following in handle_aligned_attribute, for the > case when we have no args: > align_expr = size_int (ATTRIBUTE_ALIGNED_VALUE / BITS_PER_UNIT); > Then, we compute the log of that alignment in check_user_alignment: > i = check_user_alignment (align_expr, true) > That's the log of the alignment in bytes, as we can see a little > further down: > SET_TYPE_ALIGN (*type, (1U << i) * BITS_PER_UNIT); > > Then, we call check_cxx_fundamental_alignment_constraints, which > recomputes the alignment (in bytes) from that log: > unsigned requested_alignment = 1U << align_log; > It then calls cxx_fundamental_alignment_p, where we compare it to > TYPE_ALIGN values, which are specified in bits. So I think we have a > mismatch there. > > Does that sound right? Yes, I think you are right on all account. > The patch below was bootstrapped and tested on x86_64-linux, without > issues, The patch looks good to me, thanks. > but I'm not convinced this code is covered by any testcase. Hmhm, looking at the test cases, accompanying the initial patch that introduced that code, I agree. I guess we should probably add a test case that uses [[gnu::aligned (val)]], with 'val' being an alignment that is greater than MAX (TYPE_ALIGN_UNIT (long_long_integer_type_node), TYPE_ALIGN_UNIT (long_double_type_node)) in the g++.dg/cpp0x/gen-attrs-*.C series of tests? -- Dodji