https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116637
--- Comment #6 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- (In reply to Greg Morse from comment #4) > the error comes from an attempt to do a malloc or calloc; it does not come > from an attempt to use the pointer.the assertion that causes the crash comes > from the malloc source code see here: No, out-of-bound write is an undefined behavior and anything can happen. For example if the out-of-bound write clobbered some internal data structure used by malloc, it may trigger an assertion in malloc.