From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32383 invoked by alias); 29 Apr 2009 11:33:25 -0000 Received: (qmail 32325 invoked by alias); 29 Apr 2009 11:33:14 -0000 Date: Wed, 29 Apr 2009 11:33:00 -0000 Message-ID: <20090429113314.32324.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/39954] [4.5 Regression] Revision 146817 caused unaligned access in gcc.dg/torture/pr26565.c In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "joseph at codesourcery dot com" 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: 2009-04/txt/msg02858.txt.bz2 ------- Comment #10 from joseph at codesourcery dot com 2009-04-29 11:33 ------- Subject: Re: [4.5 Regression] Revision 146817 caused unaligned access in gcc.dg/torture/pr26565.c On Wed, 29 Apr 2009, matz at gcc dot gnu dot org wrote: > The user should have the possibility to announce the unalignedness to the > compiler via casts, like so: > > memcpy((char*)&outdata->tv, tp, sizeof outdata->tv); > > (or void* or whatever). This doesn't work currently, as the emitted gimple > code loses that cast. > > So, there're two things: explicit alignment changing casts are lost and > the type of ADDR_EXPR of non-naturally aligned fields has the wrong pointer > type (losing the unalignedness). > > The former problem is a bit problematic to solve, as parameter passing > always has an implicit conversion to the formal parameter type (void* in this > case). We don't want to lose alignment info just because of that conversion, > only for explicit ones. In ISO C terms casts change alignment information in the opposite direction to the one you want - if the conversion sequence contains anywhere a pointer to an N-byte aligned type, you can assume that the pointer is N-byte aligned, so you take the highest alignment from the sequence of types, not the lowest. The problem is representing the address of an unaligned field as a pointer-to-aligned-type. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39954