On Sep 7, 2007, at 1:53 PM, Martin Jambor wrote:
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?
It is unclear whether this is safe. Nothing in the standard AFAIK requires the operator new be implemented in terms of malloc, and users are allowed to override it.
-Chris