From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3365 invoked by alias); 5 May 2010 19:40:32 -0000 Received: (qmail 3044 invoked by uid 48); 5 May 2010 19:39:39 -0000 Date: Wed, 05 May 2010 19:40:00 -0000 Message-ID: <20100505193939.3043.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/43976] warning about increased alignment during casting printed even though variable is properly aligned In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "thiago at kde dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-05/txt/msg00477.txt.bz2 ------- 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 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