https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
LIU Hao <lh_mouse at 126 dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lh_mouse at 126 dot com
--- Comment #6 from LIU Hao <lh_mouse at 126 dot com> ---
We have been experiencing this on mingw-w64 too. The warning can be caused by
```
void*
teb(void)
{
void* self;
__asm__ ("movq %%gs:%1, %0" : "=r"(self) : "m"(*(void**) 0x30));
return self;
}
```
```
<source>:5:52: warning: array subscript 0 is outside array bounds of 'void
*[0]' [-Warray-bounds]
5 | __asm__ ("movq %%gs:%1, %0" : "=r"(self) : "m"(*(void**) 0x30));
|
```
GCC 11 emits no such warning.
(godbolt: https://gcc.godbolt.org/z/sG7fG9x9j)
Apparently GCC thinks we are dereferencing `0x30` which is a dangling pointer
however that is exactly what we want to do, so GCC shouldn't have warned in
this case.