Hi, On Sun, Sep 09, 2007 at 12:56:25PM -0700, Mark Mitchell wrote: > For a particular implementation of "operator new" (such as the one in > libstdc++), you can of course make it safe in the same way as "malloc"; > hide the implementation somewhere the rest of the program can't see it > (modulo LTO). But, to declare it with the "malloc" attribute in the > headers seems dangerous, since we have no way of knowing if the user > replaced it, off in some file somewhere we don't know about, but in such > a way that pointers in our source code are being laundered back to us.
All I attempted to do was to mark just one particular implementation of the new operator which also happened to be the default built-in one. From my experiments, it appears that marking it as malloc in the libstc++ headers does not affect other implementations. However, as Gabriel Dos Reis correctly pointed out, the attribute is not applied to the new operator if the changed declaration is not somehow included in the compiled source. Fixing this inconsistency requires some changes in the FE. Nevertheless, so far I do not see problems with declaring standard new implementation as malloc in the header file. I hope you all agree that marking the default (and only the default), implementation as malloc is worthwhile and will look into it(, even though it is going to take some time). Martin