public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC] Marking C++ new operator as malloc?
@ 2007-09-07 20:54 Martin Jambor
  2007-09-08  1:26 ` Kaveh R. GHAZI
  2007-09-08  1:30 ` Chris Lattner
  0 siblings, 2 replies; 57+ messages in thread
From: Martin Jambor @ 2007-09-07 20:54 UTC (permalink / raw)
  To: GCC Mailing List

Hi,

when trying  to analyse dynamically  allocated objects in C++,  I came
across the need to identify results  of the new operator (at least the
non-overridden  standard  one)   as  malloc-allocated.   The  cleanest
approach would probably be to  mark the new operator function with the
malloc attribute.   So I did  that (see the extra-short  patch below),
bootstrapped c  and c++ on  i686-linux (with "all,fold"  checking) and
ran the test suite. To my surprise, there were no new regressions.

I  am  now  wondering  why  the  function  is  not  marked  as  malloc
already. In fact, its implementation  always returns what it gets from
the built-in malloc. Are there  any known issues or concerns with this
that the test suite cannot reveal? Can anyone comment on this?

Moreover, just before sending this  email, I have found out that there
is  already PR23383  (builtin array  operator new  is not  marked with
malloc attribute) about  the array variant of the  new operator. Given
its implementation, it is probably the same thing...

Thank you very much in advance,

Martin



Index: libstdc++-v3/libsupc++/new
===================================================================
--- libstdc++-v3/libsupc++/new	(revision 128207)
+++ libstdc++-v3/libsupc++/new	(working copy)
@@ -92,7 +92,8 @@
  *  Placement new and delete signatures (take a memory address argument,
  *  does nothing) may not be replaced by a user's program.
 */
-void* operator new(std::size_t) throw (std::bad_alloc);
+void* operator new(std::size_t) throw (std::bad_alloc) 
+    __attribute__ ((malloc));
 void* operator new[](std::size_t) throw (std::bad_alloc);
 void operator delete(void*) throw();
 void operator delete[](void*) throw();


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

end of thread, other threads:[~2007-09-14  1:33 UTC | newest]

Thread overview: 57+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-07 20:54 [RFC] Marking C++ new operator as malloc? Martin Jambor
2007-09-08  1:26 ` Kaveh R. GHAZI
2007-09-08  1:30 ` Chris Lattner
2007-09-08  5:12   ` Joe Buck
2007-09-08  5:50     ` Gabriel Dos Reis
2007-09-08 14:45       ` H.J. Lu
2007-09-09  2:33         ` Martin Jambor
2007-09-08 20:06     ` Chris Lattner
2007-09-08 20:17       ` Basile STARYNKEVITCH
2007-09-09  1:36         ` Joe Buck
2007-09-09  1:44         ` Martin Jambor
2007-09-08 20:21       ` Richard Guenther
2007-09-08 21:26         ` Gabriel Dos Reis
2007-09-09  1:35           ` Joe Buck
2007-09-09  2:33             ` Gabriel Dos Reis
2007-09-09 17:34               ` Ross Smith
2007-09-09 17:49                 ` Richard Guenther
2007-09-09 19:24                   ` Mark Mitchell
2007-09-09 19:42                     ` Joe Buck
2007-09-09 19:56                       ` Mark Mitchell
2007-09-09 20:04                         ` Richard Guenther
2007-09-09 20:22                           ` Mark Mitchell
2007-09-09 20:27                             ` Richard Guenther
2007-09-09 20:32                               ` Mark Mitchell
2007-09-09 20:38                                 ` Richard Guenther
2007-09-09 20:41                                   ` Richard Guenther
2007-09-09 21:05                                     ` Mark Mitchell
2007-09-09 20:46                                   ` Mark Mitchell
2007-09-09 21:00                                     ` Richard Guenther
2007-09-09 21:13                                       ` Mark Mitchell
2007-09-09 21:32                                         ` Richard Guenther
2007-09-09 22:23                                           ` Mark Mitchell
2007-09-10  6:56                                             ` Richard Guenther
2007-09-11  4:17                                               ` Mark Mitchell
2007-09-11  9:16                                                 ` Richard Guenther
2007-09-11 12:17                                                   ` Gabriel Dos Reis
2007-09-11 12:24                                                     ` Richard Guenther
2007-09-11 22:09                                                   ` Mark Mitchell
2007-09-10 14:43                                     ` Tom Tromey
2007-09-10 17:40                                       ` Daniel Berlin
2007-09-09 21:27                               ` Gabriel Dos Reis
2007-09-09 21:25                           ` Gabriel Dos Reis
2007-09-10 12:18                         ` Martin Jambor
2007-09-09 19:51                     ` Richard Guenther
2007-09-09 20:08                       ` Richard Guenther
2007-09-12  1:15                         ` Ian Lance Taylor
2007-09-12  8:01                           ` Richard Guenther
2007-09-12 15:14                             ` Ian Lance Taylor
2007-09-12 15:18                               ` Richard Guenther
2007-09-09 21:22                     ` Gabriel Dos Reis
2007-09-09 19:15                 ` Joe Buck
2007-09-09  2:10   ` Martin Jambor
2007-09-09  2:38     ` Gabriel Dos Reis
2007-09-13 23:38   ` Andrew Pinski
2007-09-14  0:29     ` Gabriel Dos Reis
2007-09-14  1:00       ` Andrew Pinski
2007-09-14  1:33         ` Gabriel Dos Reis

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