public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/3414: Inaccurate documentation of __attribute__((malloc))
@ 2003-03-27 21:04 neroden
  0 siblings, 0 replies; 3+ messages in thread
From: neroden @ 2003-03-27 21:04 UTC (permalink / raw)
  To: bje, gcc-bugs, gcc-prs, h.b.furuseth

Synopsis: Inaccurate documentation of __attribute__((malloc))

State-Changed-From-To: open->analyzed
State-Changed-By: neroden
State-Changed-When: Thu Mar 27 21:01:26 2003
State-Changed-Why:
    Analyzed indeed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3414


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c/3414: Inaccurate documentation of __attribute__((malloc))
@ 2003-02-18  2:54 bje
  0 siblings, 0 replies; 3+ messages in thread
From: bje @ 2003-02-18  2:54 UTC (permalink / raw)
  To: bje, gcc-bugs, gcc-prs, h.b.furuseth, nobody

Synopsis: Inaccurate documentation of __attribute__((malloc))

Responsible-Changed-From-To: unassigned->bje
Responsible-Changed-By: bje
Responsible-Changed-When: Tue Feb 18 02:54:08 2003
Responsible-Changed-Why:
    Got it.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3414


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c/3414: Inaccurate documentation of __attribute__((malloc))
@ 2001-06-25 13:36 Hallvard B Furuseth
  0 siblings, 0 replies; 3+ messages in thread
From: Hallvard B Furuseth @ 2001-06-25 13:36 UTC (permalink / raw)
  To: gcc-gnats; +Cc: h.b.furuseth

>Number:         3414
>Category:       c
>Synopsis:       Inaccurate documentation of __attribute__((malloc))
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 25 13:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Hallvard B Furuseth
>Release:        3.0
>Organization:
>Environment:
System: SunOS bombur.uio.no 5.8 Generic_108528-03 sun4u sparc SUNW,Ultra-5_10
Architecture: sun4

	
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: ./configure --quiet --enable-version-specific-runtime-libs --prefix=/usit/bombur/hbf --program-suffix=-3.0
>Description:
        From @item malloc, @node Function Attributes:

        "The `malloc' attribute is used to tell the compiler that a
        function may be treated as if it were the malloc function."

	The compiler could assume several things about that; e.g.
	that the return value will be aligned for any data type.
	However, the rest of the paragraph is:

	"The compiler assumes that calls to malloc result in a
	pointers that cannot alias anything.  This will often
	improve optimization."

	Is this the *only* assumption __attribute__((malloc)) causes?

	Incidentally, it also assumes that the program uses malloc
	correctly - here is a malloc which _can_ alias something:
	  free(x = malloc(10));
	  if (x == (y = malloc(10))) { ... }

	(BTW, typo: "a pointers" should be "a pointer".

	
>How-To-Repeat:
	
>Fix:
	I'm guessing that you mean something like this, but I
	have not checked.  Sorry if my English is a bit clumsy:

        The @code{malloc} attribute is used to tell the compiler
        that a function returns a pointer which cannot alias
        anything (or a null pointer), i.e. i behaves like the
        @code{malloc} function.  This will often improve
        optimization.

	Note that this may break programs that incorrectly uses
	the value of such a pointer after it has been
	invalidated (in the case of malloced pointers by calling
	@code{free()}, even if the pointer is not dereferenced.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-03-27 21:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-27 21:04 c/3414: Inaccurate documentation of __attribute__((malloc)) neroden
  -- strict thread matches above, loose matches on Subject: below --
2003-02-18  2:54 bje
2001-06-25 13:36 Hallvard B Furuseth

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).