This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/67618] malloc+memset optimization breaks code


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]