https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93848
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |NEW CC| |msebor at gcc dot gnu.org Component|c |middle-end See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=93514 Blocks| |56456 Severity|normal |enhancement --- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> --- The warning is emitted for the original test case once it's made clear that bar_aux dereferences the pointer using the access attribute: __attribute__ ((access (read_write, 1))) void bar_aux (int *); But in the absence of any evidence that the past-the-end pointer is dereferenced, it can't, in general, be diagnosed without causing false positives such as in calls to functions that take two pointers of compatible types: void baz_aux (int *, int *); The function could be called on a range: int a[3]; baz_aux (a, a + 3); as often happens in C++ (many functions in the standard library take two iterators delineating a range as arguments, and are often called just like the one above). But I do think issuing a warning for a subset of these cases would be safe and helpful. For instance, when passing a past-the-end pointer to a function that takes just a single pointer would be okay because the function in all likelihood does dereference it. I recently opened bug 93514 noting this problem in calls to built-ins (pr93514). There, the past-the-end pointer is certain to be accessed by the function, but the warning doesn't have the logic to detect it. Anyway, let me confirm this report as an enhancement request for a warning along the lines of the idea in bug 93514 comment 1. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456 [Bug 56456] [meta-bug] bogus/missing -Warray-bounds