This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, PR43814] Assume function arguments of pointer type are aligned.


On Thu, Sep 29, 2011 at 12:51 PM, Bernd Schmidt <bernds@codesourcery.com> wrote:
> On 09/29/11 11:26, Richard Guenther wrote:
>> Maybe that was the PR the patch is about, but surely we can't treat
>> a memcpy (p, ..) like *p. ?Which means we'd use the declared type
>> of p only. ?And we can do so only for parameters (intermediate conversions
>> are dropped), which would make the case apply to artificial testcases only
>> (and thus not worth).
>
> Didn't we used to do exactly that, though?

Yes we did.  The point is this is all language semantics and we are not
good at expressing it given the various GCC extensions we have.

struct { int i; } __attribute__((aligned(1))) x;

and &x->i will have type int *, not int __attribute__((aligned(1))) *.
Basically because we share FIELD_DECLs for type variants and
alignment consitutes a variant, the FIELD_DECL has natural
alignment and whenever the context (that we access a component of x)
vanishes the alignment information vanishes.

Thus, the middle-end cannot reasonably derive anything from type
alignment.  Because the frontends get it wrong.  Which means we
used to miscompile valid code (using GCC extensions, of course).

Richard.

> Googling shows
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=325670
>
> but I seem to remember PRs in gcc bugzilla marked not a bug. Or maybe my
> memory is playing tricks on me.
>
>
> Bernd
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]