From: Jakub Jelinek <jakub@redhat.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: Yury Gribov <y.gribov@samsung.com>,
GCC Patches <gcc-patches@gcc.gnu.org>,
Marek Polacek <polacek@redhat.com>,
Andrey Ryabinin <a.ryabinin@samsung.com>
Subject: Re: [PATCH] Fix minimal alignment calculation for user-aligned types (PR63802)
Date: Mon, 17 Nov 2014 18:22:00 -0000 [thread overview]
Message-ID: <20141117175425.GD1745@tucnak.redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1411171738220.24344@digraph.polyomino.org.uk>
On Mon, Nov 17, 2014 at 05:46:55PM +0000, Joseph Myers wrote:
> On Mon, 17 Nov 2014, Jakub Jelinek wrote:
>
> > > If it is true that a type satisfying TYPE_USER_ALIGN will never be
> > > allocated at an address less-aligned than its TYPE_ALIGN, even if that's
> > > greater than BIGGEST_ALIGNMENT, then the change seems correct for C11
> > > _Alignof.
> >
> > I think it depends on which target and where.
> > In structs (unless packed) the user aligned fields should be properly
> > aligned with respect to start of struct and the struct should have user
> > alignment in that case, automatic vars these days use alloca with
> > realignment if not handled better by the target, so should be fine too.
> > For data section vars and for common vars I think it really depends on the
> > target. Perhaps for TYPE_USER_ALIGN use minimum of the TYPE_ALIGN and
> > MAX_OFILE_ALIGNMENT ?
> > For heap objects, it really depends on how it has been allocated, but if
> > allocated through malloc, the extra alignment is never guaranteed.
> > So, it really depends in malloc counts or not.
>
> 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?
Jakub
next prev parent reply other threads:[~2014-11-17 17:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-14 7:00 Yury Gribov
2014-11-14 7:18 ` Jakub Jelinek
2014-11-14 7:42 ` Yury Gribov
2014-11-14 18:25 ` Joseph Myers
2014-11-17 8:15 ` Jakub Jelinek
2014-11-17 14:50 ` [PATCHv2] " Yury Gribov
2014-11-17 14:59 ` Joseph Myers
2014-11-17 18:21 ` [PATCH] " Joseph Myers
2014-11-17 18:22 ` Jakub Jelinek [this message]
2014-11-17 18:55 ` Joseph Myers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141117175425.GD1745@tucnak.redhat.com \
--to=jakub@redhat.com \
--cc=a.ryabinin@samsung.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
--cc=polacek@redhat.com \
--cc=y.gribov@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).