public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mark at codesourcery dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/23561] nonoverlapping_memrefs_p returns true even for overlapping memory references
Date: Thu, 25 Aug 2005 17:23:00 -0000	[thread overview]
Message-ID: <20050825172238.32223.qmail@sourceware.org> (raw)
In-Reply-To: <20050825153435.23561.jakub@gcc.gnu.org>


------- Additional Comments From mark at codesourcery dot com  2005-08-25 17:22 -------
Subject: Re:  nonoverlapping_memrefs_p returns
 true even for overlapping memory references

rth at gcc dot gnu dot org wrote:

> And in the case in question, it's quite obviously an off-by-one bug on the
> part of the programmer.  They did not really intend to initialize a3[0] twice.
> So I think it would be useful if _FORTIFY_SOURCE complained about this usage
> even if it turns out to be within the letter of the law.

We did seem to reach the consensus that it was OK to upcast from a 
member of the structure to the containing structure, or, rather, that 
there was nothing that definitively made that invalid.

This is a bit different, in that the problematic memcpy is not 
mentioning a3 at all; it's just stepping on it.  I'm not sure whether 
this case is valid; my guess is that it is, simply in that the C 
standard says so little about the object model that one rather has to 
assume such things are legal.  Then again, you're not strictly pseaking 
allowed to index off the end of an array, so I'm not sure.

However, if memcpy were an arbitrary function, then by the conclusion in 
the first paragraph, it certainly might modify "a.a3".  So, the compiler 
must be making some special assumption about memcpy.  I'd suggest 
ceasing to make that assumption, in the name of caution.

I agree that in an error-checking capacity it makes sense to warn.  As 
RTH says, this is not something that programmers mean to do.



-- 


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


  parent reply	other threads:[~2005-08-25 17:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-25 15:39 [Bug rtl-optimization/23561] New: " jakub at gcc dot gnu dot org
2005-08-25 15:48 ` [Bug rtl-optimization/23561] " pinskia at gcc dot gnu dot org
2005-08-25 15:53 ` jakub at gcc dot gnu dot org
2005-08-25 15:54   ` Andrew Pinski
2005-08-25 16:11 ` pinskia at physics dot uc dot edu
2005-08-25 16:36 ` rth at gcc dot gnu dot org
2005-08-25 16:42 ` rth at gcc dot gnu dot org
2005-08-25 17:23 ` mark at codesourcery dot com [this message]
2005-08-25 19:06 ` jakub at gcc dot gnu dot org
2005-08-26 22:03 ` cvs-commit at gcc dot gnu dot org
2005-08-27 12:04 ` cvs-commit at gcc dot gnu dot org
2005-09-02  8:49 ` jakub at gcc dot gnu dot org
2005-09-07 14:12 ` pinskia at gcc dot gnu dot 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=20050825172238.32223.qmail@sourceware.org \
    --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).