[Bug c++/23383] builtin array operator new is not marked with malloc attribute
xinliangli at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Jan 5 18:55:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23383
--- Comment #22 from davidxl <xinliangli at gmail dot com> 2012-01-05 18:54:51 UTC ---
(In reply to comment #21)
> But can't a valid code also compare the result from realloc with the old
> pointer, and if they are equal, do something, otherwise do something else?
> I think it is pretty common e.g. if the malloced block contains pointers to
> parts of the malloced area and upon realloc that didn't return the passed
> address wants to adjust all those pointers.
> Having a malloc attribute on realloc would still break this.
> I'd say we want realloc attribute and handle it where we currently handle
> BUILT_IN_REALLOC.
Right, the case you describe may be common. On the other hand, the compiler
probably should not optimize away pointer comparisons without knowing if the
pointer is used after 'free' or 'free' like function 'realloc'.
David
More information about the Gcc-bugs
mailing list