This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Funny bug
- To: poulot at sunchorus dot france dot sun dot com
- Subject: Re: Funny bug
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Wed, 1 Mar 2000 01:03:03 +0100
- CC: bug-gcc at gnu dot org, <oliva at lsd dot ic dot unicamp dot br>, gcc-patches at gcc dot gnu dot org
- References: <ln4sawsu5a.fsf@walhalla.agaha>
> extern void malloc(size_t size);
>
> toto()
> {
> malloc(100);
> }
Thanks for your bug report. Here is a patch.
Martin
2000-03-01 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* call.c (special_function_p): It is only malloc if it returns
Pmode.
Index: calls.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/calls.c,v
retrieving revision 1.84
diff -u -p -r1.84 calls.c
--- calls.c 2000/02/28 11:55:43 1.84
+++ calls.c 2000/02/29 23:19:39
@@ -630,15 +630,16 @@ special_function_p (fndecl, returns_twic
instead mark them as malloc functions using the malloc attribute.
Note, realloc is not suitable for attribute malloc since
it may return the same address across multiple calls. */
- else if (! strcmp (tname, "malloc")
- || ! strcmp (tname, "calloc")
- || ! strcmp (tname, "strdup")
- /* Note use of NAME rather than TNAME here. These functions
- are only reserved when preceded with __. */
- || ! strcmp (name, "__vn") /* mangled __builtin_vec_new */
- || ! strcmp (name, "__nw") /* mangled __builtin_new */
- || ! strcmp (name, "__builtin_new")
- || ! strcmp (name, "__builtin_vec_new"))
+ else if (TYPE_MODE (TREE_TYPE (TREE_TYPE (fndecl))) == Pmode
+ &&(! strcmp (tname, "malloc")
+ || ! strcmp (tname, "calloc")
+ || ! strcmp (tname, "strdup")
+ /* Note use of NAME rather than TNAME here. These functions
+ are only reserved when preceded with __. */
+ || ! strcmp (name, "__vn") /* mangled __builtin_vec_new */
+ || ! strcmp (name, "__nw") /* mangled __builtin_new */
+ || ! strcmp (name, "__builtin_new")
+ || ! strcmp (name, "__builtin_vec_new")))
*is_malloc = 1;
}
}