This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR48493
- From: Richard Biener <rguenther at suse dot de>
- To: Mike Stump <mikestump at comcast dot net>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 09 Aug 2013 15:29:02 +0200
- Subject: Re: [PATCH] Fix PR48493
- References: <Pine dot LNX dot 4 dot 64 dot 1205311258260 dot 5860 at jbgna dot fhfr dot qr> <A4FFF2DB-E461-4C5C-BCBD-A689FF5F0C28 at comcast dot net>
On 8/9/13 1:29 AM, Mike Stump wrote:
> In the below, the test case tries to write to the stack outside the bounds of the s variable? I can't imagine any good coming from this, and indeed, would be nice for the compiler to complain about such code. If S had a few more bytes at the end, at least the code would not be wildly bad.
>
> Thoughts?
It's not that easy - you need to make sure the variable is promoted to a
register, too. Feel free to experiment but make sure the testcase
fails in the same way before the patch went in.
Richard.
> On May 31, 2012, at 3:59 AM, Richard Guenther <rguenther@suse.de> wrote:
>> This fixes PR48493 by backporting a one-liner - we should not go
>> the movmisalign path for destinations that are not memory.
>>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu and on
>> mips by Andrew, installed.
>>
>> Richard.
>>
>> 2012-05-31 Richard Guenther <rguenther@suse.de>
>>
>> PR middle-end/48493
>> * expr.c (expand_assignment): Do not use movmisalign on
>> non-memory.
>>
>> * gcc.dg/torture/pr48493.c: New testcase.
>
>> Index: gcc/testsuite/gcc.dg/torture/pr48493.c
>> ===================================================================
>> *** gcc/testsuite/gcc.dg/torture/pr48493.c (revision 0)
>> --- gcc/testsuite/gcc.dg/torture/pr48493.c (revision 0)
>> ***************
>> *** 0 ****
>> --- 1,18 ----
>> + /* { dg-do compile } */
>> +
>> + typedef long long T __attribute__((may_alias, aligned (1)));
>> +
>> + struct S
>> + {
>> + _Complex float d __attribute__((aligned (8)));
>> + };
>> +
>> + void bar (struct S);
>> +
>> + void
>> + f1 (T x)
>> + {
>> + struct S s;
>> + *(T *) ((char *) &s.d + 1) = x;
>> + bar (s);
>> + }
>