Funny bug
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Tue Feb 29 16:08:00 GMT 2000
> 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;
}
}
More information about the Gcc-bugs
mailing list