This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/67618] malloc+memset optimization breaks code
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 17 Sep 2015 20:13:54 +0000
- Subject: [Bug c/67618] malloc+memset optimization breaks code
- Auto-submitted: auto-generated
- References: <bug-67618-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67618
Marc Glisse <glisse at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |c
--- Comment #7 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Daniel Gutson from comment #4)
> The optimization ignores the 'if' statement (just comment that line and
> see), so if malloc() returns NULL, memset is called unconditionally and will
> try to write to address NULL.
Ah, you are saying that calling memset on a null pointer is not undefined
behavior, that it generates an observable trap, and that the transformation
should be protected by -fdelete-null-pointer-checks?