On Fri, 2023-04-21 at 10:52 +0300, Yuri Kanivetsky via Gcc-help wrote: > The culprit supposedly found. fortify-headers makes memcpy() assert > that source and destination shouldn't overlap, and when they do it > calls __builtin_trap(): > > http://git.2f30.org/fortify-headers/file/include/string.h.html#l46 > > PerlIO::eol in its turn uses memcpy() to remove symbols from a string > (source and destination overlaps). The questions that are left are: > > 1) Is fortify-headers too strict, or PerlIO::eol should be fixed? Then you should use memmove instead of memcpy. > 2) What -O0 has to do with this? -D_FORTIFY_SOURCE=2 has no effect with -O0: $ cc hw.c -D_FORTIFY_SOURCE=2 -O0 In file included from /usr/include/bits/libc-header-start.h:33, from /usr/include/stdio.h:27, from hw.c:1: /usr/include/features.h:413:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp] 413 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) | ^~~~~~~ -- Xi Ruoyao <xry111@xxxxxxxxxxx> School of Aerospace Science and Technology, Xidian University