https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91258
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|NEW |ASSIGNED
--- Comment #13 from Martin Sebor <msebor at gcc dot gnu.org> ---
-fdump-tree-xxx options don't seem to work with LTO but here's the dump of
debug_function() called from pass_strlen::execute (function *fun) with the
problem MEM_REF marked up by <<<. I don't know enough about LTO or UBSAN to
tell why the int array in the code is trasnformed into a char array but since
they're the same size I'll assume it's not wrong. The simplest "fix" for the
failing test is to suppress the (valid) warning.
$ /build/gcc-trunk/gcc/testsuite/g++/../../xg++
-B/build/gcc-trunk/gcc/testsuite/g++/../../
/src/gcc/trunk/gcc/testsuite/g++.dg/ubsan/vla-1.C -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects -Wno-vla -fsanitize=undefined
-B/build/gcc-trunk/powerpc64-unknown-linux-gnu/./libsanitizer/
-B/build/gcc-trunk/powerpc64-unknown-linux-gnu/./libsanitizer/ubsan/
-L/build/gcc-trunk/powerpc64-unknown-linux-gnu/./libsanitizer/ubsan/.libs
-L/build/gcc-trunk/powerpc64-unknown-linux-gnu/./libstdc++-v3/src/.libs
-B/build/gcc-trunk/powerpc64-unknown-linux-gnu/./libstdc++-v3/src/.libs
-L/build/gcc-trunk/powerpc64-unknown-linux-gnu/./libstdc++-v3/src/.libs -o
/dev/null
main ()
{
unsigned char D.3146[4];
int[0:D.3139] * ar.0;
sizetype D.3139;
void * _3;
<bb 2> [local count: 1073741833]:
_3 = __builtin_stack_save ();
.UBSAN_BOUNDS (0B, 1, 0);
.UBSAN_NULL (&D.3146, 1B, 4);
MEM[(int *)&D.3146] = 42;
.UBSAN_PTR (&D.3146, 4);
.UBSAN_NULL (&MEM <int[0:D.3139]> [(void *)&D.3146 + 4B], 1B, 4);
.UBSAN_OBJECT_SIZE (&MEM <int[0:D.3139]> [(void *)&D.3146 + 4B], 8, 4, 1);
MEM[(int *)&D.3146 + 4B] = 24;
<<< write past the end
.UBSAN_PTR (&MEM <int[0:D.3139]> [(void *)&D.3146 + 4B], 4);
D.3146 ={v} {CLOBBER};
__builtin_stack_restore (_3);
return 0;
}
In function ‘f’,
inlined from ‘main’ at
/src/gcc/trunk/gcc/testsuite/g++.dg/ubsan/vla-1.C:11:4:
/src/gcc/trunk/gcc/testsuite/g++.dg/ubsan/vla-1.C:6:24: warning: writing 4
bytes into a region of size 0 [-Wstringop-overflow=]
6 | int ar[i] = { 42, 24 };
| ^