This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/78902] Missed malloc optimizations: malloc w/o LHS and zero argument
- From: "marxin at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 22 Dec 2016 14:30:53 +0000
- Subject: [Bug tree-optimization/78902] Missed malloc optimizations: malloc w/o LHS and zero argument
- Auto-submitted: auto-generated
- References: <bug-78902-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78902
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #2)
> The p=malloc(0) transformation looks strange.
> (I never know if we are supposed to unlink_stmt_vdef, etc)
Yep, it's strange, should be p = NULL. As mentioned in MAN page:
If size is 0, then malloc() returns either NULL, or a unique pointer value that
can later be successfully passed to free().
I'll prepare regular patch and send it to ML.