public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thiago at kde dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/43976] warning about increased alignment during casting printed even though variable is properly aligned
Date: Wed, 05 May 2010 19:40:00 -0000	[thread overview]
Message-ID: <20100505193939.3043.qmail@sourceware.org> (raw)
In-Reply-To: <bug-43976-7726@http.gcc.gnu.org/bugzilla/>



------- Comment #4 from thiago at kde dot org  2010-05-05 19:39 -------
(In reply to comment #3)
> The struct Foo looks like an odd way to try and express
> 
> union Foo
> {
>   int i;
>   char c[sizeof (int)];
> };

Well, that is the objective, but you can't replace int with a non-POD type in
C++98. C++0x relaxes the unions and that's exactly what is intended: delayed
construction.

I used int as an example, but the objective is to have:

template <typename T>
struct Buffer
{
    char __attribute__((aligned(__alignof__(T)))) buf[sizeof(T)];
};

[the WebKit WTF::Vector code is a bit more complex than that to get around the
fact that gcc 4.2 can't do aligned(__alignof__(T)), so it partially specialises
alignments of 1, 2, 4, 8, 16, and 64]


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43976


  parent reply	other threads:[~2010-05-05 19:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-03 14:40 [Bug c++/43976] New: " thiago at kde dot org
2010-05-04 17:27 ` [Bug middle-end/43976] " pinskia at gcc dot gnu dot org
2010-05-04 19:40 ` thiago at kde dot org
2010-05-05 19:18 ` hp at gcc dot gnu dot org
2010-05-05 19:40 ` thiago at kde dot org [this message]
2010-09-08 10:02 ` ibolton at gcc dot gnu dot org

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=20100505193939.3043.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).