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 other/56955] documentation for attribute malloc contradicts itself
Date: Mon, 15 Apr 2013 10:19:00 -0000	[thread overview]
Message-ID: <bug-56955-4-gjoacbP2lO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56955-4@http.gcc.gnu.org/bugzilla/>


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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-15 10:19:22 UTC ---
(In reply to comment #2)
> (In reply to comment #1)
> > I think it is talking about the memory returned by malloc/calloc will not point
> > to another memory location while realloc can.
> 
> I agree that's essentially what it ought to talk about, and the bug is that
> it's talking about something else -- the contents of the pointed-to memory.

Well, it _is_ actually about the content.  There must be no way to compute
a valid pointer to another object from the contents of the pointed-to
memory.  So if you initialize the memory to {0, 1, 2, 3, 4 ...} thus
every possible byte value is somewhere and then do

  void *p = (void *)(mem[3] << 24 | mem[58] << 16 | ...);

then points-to analysis assumes that from the contents of 'mem' you
can only compute pointers to nothing (NULL).  Technically for targets
where NULL is a valid poiner to an object calloc () may not be marked
with malloc.

That is, read it in the way that the code assumes the memory _may_ be
zero-initialized (but only zero-initialized) or uninitialized.


  parent reply	other threads:[~2013-04-15 10:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-56955-4@http.gcc.gnu.org/bugzilla/>
2013-04-14 19:05 ` pinskia at gcc dot gnu.org
2013-04-14 19:47 ` sunfish at google dot com
2013-04-15 10:19 ` rguenth at gcc dot gnu.org [this message]
2013-04-15 14:53 ` sunfish at google dot com
2014-05-20 20:41 ` eggert at gnu dot org
2014-05-20 20:49 ` carlos at redhat dot com
2014-05-20 20:51 ` eggert at gnu dot org
2014-05-20 21:00 ` bugdal at aerifal dot cx
2014-05-21  0:31 ` eggert at gnu dot org
2014-05-21  1:26 ` sunfish at mozilla dot com
2014-05-21  4:22 ` eggert at gnu dot org
2014-05-21 12:09 ` rguenth at gcc dot gnu.org
2014-05-21 13:09 ` rguenth at gcc dot gnu.org
2014-05-21 14:33 ` sunfish at mozilla dot com
2014-05-21 15:14 ` eggert at gnu dot org
2014-05-22 14:14 ` eggert at gnu dot org
2014-05-23 10:11 ` rguenth at gcc dot gnu.org
2014-05-23 10:13 ` 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-56955-4-gjoacbP2lO@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).