| Issue |
179128
|
| Summary |
[bug report] Clang++ gives no -Warray-bounds warning when you call a member function of an item outside bounds?
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
xealits
|
I am not sure if it is a bug, because GCC does the same thing. If you *call* a member of an item outside bounds, `-Warray-bounds` warning does not show up: ([godbolt link](https://godbolt.org/z/fzzx7KWEY))
```Cpp
struct CallableInt {
int x = 5;
int call(void) {
return x;
}
};
int main() {
//int x[10] = {0};
//return x[40]; // -Warray-bounds warning
CallableInt x[10] = {};
//return x[40].x; // still warning
return x[40].call(); // no warning
}
```
It is compiled with:
```
clang++ -Wall -Warray-bounds -std=c++20 warray_bounds_example.cpp
```
Clang version:
```
$ clang++ --version
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```
And versions 20 and 21 behave the same way on godbolt.
Is this an expected behavior?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs