https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85420
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2018-04-16 CC| |msebor at gcc dot gnu.org Component|middle-end |tree-optimization Summary|More -Wrestrict false |missing -Wrestrict with |positives with |-fsanitize=undefined |-fsanitize=undefined | Ever confirmed|0 |1 --- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> --- The warning for attachment 43950 is intended and the bug is actually in failing to issue it without -fsanitize=undefined. Unlike for raw memory functions such as memcpy, for string functions like strcpy -Wrestrict triggers even for possible overlaps. I.e., copying a substring of the same array is designed to warn whether or not the overlap is certain, as in: char a[32]; void f (int i) { __builtin_strcpy (a, a + i); // -Wrestrict expected here } This doesn't work completely consistently -- e.g., the above won't warn if a is changed to a pointer -- but the basic idea is that strcpy is too "unpredictable" to be safely used to copy substrings within the same array. So confirming for the missing warning. The warning in attachment 43951 looks like a different bug in -Wrestrict: it doesn't consider the sizes of the two array members and so it doesn't distinguish between them. Let me open a separate report for this.