https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109590
Bug ID: 109590
Summary: array-bounds does not warn about address 0x0
dereference
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jg at jguk dot org
Target Milestone: ---
Could -Warray-bounds give a warning when a buffer is at address 0x0 like it
does when buffers are at addresses under 0x1000 ? example below.
int main()
{
const char * n = nullptr;
const char * p = reinterpret_cast<const char*>(0x100);
return *n + *p;
}
https://godbolt.org/z/n6ffhfEn9
<source>: In function 'int main()':
<source>:7:17: warning: array subscript 0 is outside array bounds of 'const
char [0]' [-Warray-bounds=]
7 | return *n + *p;
| ^~
cc1plus: note: source object is likely at address zero
Compiler returned: 0
I know the --param=min-pagesize default is 0x1000 so I had expected the warning
to occur on 0x0 as well as 0x100 in this example