public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/50460] [4.7 Regression] __builtin___strcpy_chk/__builtin_object_size don't work
Date: Wed, 28 Sep 2011 12:29:00 -0000	[thread overview]
Message-ID: <bug-50460-4-HfONlI1Y36@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-50460-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50460

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-28 12:23:15 UTC ---
Btw, this is equivalent to a missing diagnostic, it's correctly not trapping
similar as to if it didn't know anything about the object that is refered to.

Indeed when I disable the folding during gimplification CCP comes along
and does

 <bb 2>:
   str1.0_1 = str1;
   D.2732_2 = str1.0_1 + 5;
-  D.2733_3 = &a.buf1 + 4;
-  __dest_7 = (char * restrict) D.2733_3;
   __src_8 = (const char * restrict) D.2732_2;
-  D.2747_9 = __builtin_object_size (__dest_7, 1);
-  D.2746_10 = __builtin___strcpy_chk (__dest_7, __src_8, D.2747_9);
-  D.2746_12 = D.2746_10;
-  D.2734_4 = 0;
-  return D.2734_4;
+  D.2746_10 = __builtin___strcpy_chk (&MEM[(void *)&a + 4B], __src_8, 6);
+  return 0;

which is good, as the address is invariant.

So, short of moving the objsize pass way earlier (which I'm sure we don't
want to do), I don't see a good way to recover this diagnostic.

One possibility is to make sure try_move_mult_to_index handles the case
of &a.buf1 + 4, instead of just &a.buf1[0] + 4.  I have a patch for that.


  parent reply	other threads:[~2011-09-28 12:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-20  8:16 [Bug middle-end/50460] New: " hjl.tools at gmail dot com
2011-09-20 10:49 ` [Bug middle-end/50460] " jakub at gcc dot gnu.org
2011-09-20 13:47 ` hjl.tools at gmail dot com
2011-09-22 22:06 ` rguenth at gcc dot gnu.org
2011-09-23  8:34 ` jakub at gcc dot gnu.org
2011-09-25 11:24 ` rguenth at gcc dot gnu.org
2011-09-26  9:14 ` jakub at gcc dot gnu.org
2011-09-28 12:29 ` rguenth at gcc dot gnu.org [this message]
2011-09-28 13:52 ` rguenth at gcc dot gnu.org
2011-09-28 14:01 ` rguenth at gcc dot gnu.org

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=bug-50460-4-HfONlI1Y36@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).