https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117809
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Keywords| |missed-optimization Last reconfirmed| |2024-11-28 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- It's difficult for GCC to make use of this case optimally, but sure. On allocation failure we would need to document that *ptr either becomes undefined or NULL. We currently handle posix_memalign "by name" only. Likewise realloc() is not 'malloc' but special-cased by name. Note we unfortunately overloaded the malloc attribute when it has an argument to instead specify a corresponding deallocation function but otherwise not have the same semantic as 'malloc' without argument. That means 'malloc' semantics on a positional argument will have confusing implications. So I'd love to see a proposal, possibly also addressing the realloc case where the pointer is either the "old" or a new one not aliasing any other pointer.