This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Problem in cxx_fundamental_alignment_p?
- From: Dodji Seketeli <dodji at redhat dot com>
- To: Bernd Schmidt <bschmidt at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 01 Jul 2016 10:34:08 +0200
- Subject: Re: Problem in cxx_fundamental_alignment_p?
- Authentication-results: sourceware.org; auth=none
- References: <98900257-b106-63b6-6579-be0873a61587 at redhat dot com>
Hello Bernd,
Bernd Schmidt <bschmidt@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