https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119868
Bug ID: 119868
Summary: `'result_decl' not supported by dump_expr<expression
error>` is printed instead of `<return value> res` in
some cases
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
#include <array>
auto f(unsigned idx1, unsigned idx2)
{
std::array<char,33> res;
__builtin_strcpy(res.data(), "1234567890123456789012345678901234567890");
return res;
}
auto f1(unsigned idx1, unsigned idx2)
{
std::array<char,33> res;
for (unsigned i = idx1 + 1; i < idx2; i++)
res[i] = 1;
return res;
}
```
Compile with `-O3 -D_GLIBCXX_ASSERTIONS` (and `-mavx2` on x86_64 to get early
exit vectorization).
We get:
```
<source>: In function 'auto f()':
<source>:6:21: warning: 'void* __builtin_memcpy(void*, const void*, long
unsigned int)' forming offset [33, 40] is out of the bounds [0, 33] of object
'<return value> res' with type 'std::array<char, 33>' [-Warray-bounds=]
6 | __builtin_strcpy(res.data(),
"1234567890123456789012345678901234567890");
|
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:3:1: note: '<return value> res' declared here
3 | auto f()
| ^~~~
<source>: In function 'auto f1(unsigned int, unsigned int)':
<source>:16:16: warning: writing 32 bytes into a region of size 1
[-Wstringop-overflow=]
16 | res[i] = 1;
<source>:12:1: note: at offset [32, 33] into destination object ''result_decl'
not supported by dump_expr<expression error>' of size 33
12 | auto f1(unsigned idx1, unsigned idx2)
| ^~~~
```
Notice how in the first Warray-bounds warnings we get '<return value> res'
while in the second case we get 'result_decl' not supported by
dump_expr<expression error>.