This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix minimal alignment calculation for user-aligned types (PR63802)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Yury Gribov <y dot gribov at samsung dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Marek Polacek <polacek at redhat dot com>, Andrey Ryabinin <a dot ryabinin at samsung dot com>
- Date: Mon, 17 Nov 2014 18:29:49 +0000
- Subject: Re: [PATCH] Fix minimal alignment calculation for user-aligned types (PR63802)
- Authentication-results: sourceware.org; auth=none
- References: <5465A536 dot 8090905 at samsung dot com> <20141114070221 dot GE5026 at tucnak dot redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1411141813430 dot 1269 at digraph dot polyomino dot org dot uk> <20141117072034 dot GA4079 at tucnak dot redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1411171738220 dot 24344 at digraph dot polyomino dot org dot uk> <20141117175425 dot GD1745 at tucnak dot redhat dot com>
On Mon, 17 Nov 2014, Jakub Jelinek wrote:
> > The question, for both _Alignas and ubsan, is the alignment guaranteed *in
> > valid programs*.
> >
> > malloc only provides sufficient alignment for types with fundamental
> > alignment requirements (although there are various problems with the C11
> > wording; see DR#445). So if you use malloc to allocate a type with an
> > extended alignment requirement (without doing extra realignment on the
> > result of malloc), that's not a valid program. And if an alignment is
> > larger than MAX_OFILE_ALIGNMENT, you get an error for declaring non-stack
> > variables requiring that alignment. So I don't think there's any need to
> > check MAX_OFILE_ALIGNMENT here.
>
> If so, then Yuri's original patch (the one changing min_align_of_type)
> should be fine, right?
Yes.
--
Joseph S. Myers
joseph@codesourcery.com