https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85504
Bug ID: 85504 Summary: Bogus -Wrestrict warning with -fsanitize=undefined Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: bernd.edlinger at hotmail dot de Target Milestone: --- Created attachment 44008 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44008&action=edit unreduced test case This happens with current openssl trunk revision: ./config -fsanitize=undefined --strict-warnings $ gcc -I. -Icrypto/include -Iinclude -fPIC -pthread -m64 -Wa,--noexecstack -DDEBUG_UNUSED -DPEDANTIC -pedantic -Wno-long-long -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wswitch -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Wundef -Werror -Wall -O3 -fsanitize=undefined -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPADLOCK_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib/engines-1.1\"" -DNDEBUG -MMD -MF crypto/engine/eng_ctrl.d.tmp -MT crypto/engine/eng_ctrl.o -c -o crypto/engine/eng_ctrl.o crypto/engine/eng_ctrl.c crypto/engine/eng_ctrl.c: In function 'ENGINE_ctrl': crypto/engine/eng_ctrl.c:110:23: error: 'strcpy' source argument is the same as destination [-Werror=restrict] return strlen(strcpy(s, cdp->cmd_name)); ^~~~~~~~~~~~~~~~~~~~~~~~ while I can use -save-temps with this one (see attached test case) there is another file which does not show the error with -save-temps: $ gcc -I. -Iinclude -Iapps -pthread -m64 -Wa,--noexecstack -DDEBUG_UNUSED -DPEDANTIC -pedantic -Wno-long-long -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wswitch -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Wundef -Werror -Wall -O3 -fsanitize=undefined -DNDEBUG -MMD -MF apps/s_client.d.tmp -MT apps/s_client.o -c -o apps/s_client.o apps/s_client.c In file included from /usr/include/string.h:635, from apps/s_client.c:15: apps/s_client.c: In function 's_client_main': apps/s_client.c:2585:13: error: '__builtin_strncpy' source argument is the same as destination [-Werror=restrict] strncpy(sbuf, mbuf, 2); ^~~~~~~ $ gcc -I. -Iinclude -Iapps -pthread -m64 -Wa,--noexecstack -DDEBUG_UNUSED -DPEDANTIC -pedantic -Wno-long-long -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wswitch -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Wundef -Werror -Wall -O3 -fsanitize=undefined -DNDEBUG -MMD -MF apps/s_client.d.tmp -MT apps/s_client.o -c -o apps/s_client.o apps/s_client.c -save-temps