public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix get_inner_reference (PR middle-end/65680)
Date: Tue, 07 Apr 2015 14:21:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.11.1504071621180.5207@zhemvz.fhfr.qr> (raw)
In-Reply-To: <20150407141813.GG19273@tucnak.redhat.com>

On Tue, 7 Apr 2015, Jakub Jelinek wrote:

> Hi!
> 
> bit_offset in get_inner_reference is offset_int (i.e. a wide_int larger than
> address size).  get_inner_reference has code to handle the case when
> bit_offset is negative by splitting it into a byte offset and very small
> positive bitpos, but on the following testcase bit_offset isn't negative,
> just is too large to fit into shwi, so to the caller it incorrectly appears
> to be negative.
> 
> This patch fixes it by handling it the same, putting the large part into
> offset and just the remaining bits into bitpos in that case.
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2015-04-07  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR middle-end/65680
> 	* expr.c (get_inner_reference): Handle bit_offset that doesn't fit
> 	into signed HOST_WIDE_INT the same as negative bit_offset.
> 
> 	* gcc.c-torture/compile/pr65680.c: New test.
> 
> --- gcc/expr.c.jj	2015-03-16 17:06:30.000000000 +0100
> +++ gcc/expr.c	2015-04-07 10:16:10.365876617 +0200
> @@ -6941,7 +6941,7 @@ get_inner_reference (tree exp, HOST_WIDE
>    if (offset)
>      {
>        /* Avoid returning a negative bitpos as this may wreak havoc later.  */
> -      if (wi::neg_p (bit_offset))
> +      if (wi::neg_p (bit_offset) || !wi::fits_shwi_p (bit_offset))
>          {
>  	  offset_int mask = wi::mask <offset_int> (LOG2_BITS_PER_UNIT, false);
>  	  offset_int tem = bit_offset.and_not (mask);
> --- gcc/testsuite/gcc.c-torture/compile/pr65680.c.jj	2015-04-07 10:25:40.142632657 +0200
> +++ gcc/testsuite/gcc.c-torture/compile/pr65680.c	2015-04-07 10:25:08.000000000 +0200
> @@ -0,0 +1,20 @@
> +/* PR middle-end/65680 */
> +/* { dg-do compile { target lp64 } } */
> +
> +struct S
> +{
> +  int f : 1;
> +} a[100000000000000001][3];
> +
> +void
> +foo (void)
> +{
> +  struct S b = { 0 };
> +  a[100000000000000000][0] = b;
> +}
> +
> +void
> +bar (void)
> +{
> +  a[100000000000000000][0].f = 1;
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Jennifer Guild,
Dilip Upmanyu, Graham Norton HRB 21284 (AG Nuernberg)

      reply	other threads:[~2015-04-07 14:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 14:18 Jakub Jelinek
2015-04-07 14:21 ` Richard Biener [this message]

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=alpine.LSU.2.11.1504071621180.5207@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /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).