https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109611
Bug ID: 109611 Summary: Missing -Wrestrict across TUs (even with LTO) Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: sjames at gcc dot gnu.org CC: arsen at gcc dot gnu.org Blocks: 84774 Target Milestone: --- ``` $ cat test.c #include <string.h> char foo[200]; char* bar(char*); int main (int argc, char **argv) { strncpy (foo, bar (foo) + 50, 70); } $ cat test2.c char* bar (char* x) { return x; } ``` ``` $ gcc -flto-partition=none -flto test2.c test.c -Wrestrict -O3 [no -Wrestrict warning] ``` But by forcing them all into the same TU: ``` $ cat test{2,}.c | gcc -x c - -O3 -Wrestrict -S -o /dev/null In file included from /usr/include/string.h:535, from <stdin>:6: In function ‘strncpy’, inlined from ‘main’ at <stdin>:14:3: /usr/include/bits/string_fortified.h:95:10: warning: ‘__builtin_strncpy’ accessing 70 bytes at offsets 0 and 50 overlaps between 1 and 20 bytes at offset 50 [-Wrestrict] [...] ``` None of -fwhole-program, -flto-partition=none nor -flto-partition=one make any difference. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84774 [Bug 84774] [meta-bug] bogus/missing -Wrestrict