https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110763
Bug ID: 110763
Summary: FAIL: gcc.dg/ubsan/object-size-dyn.c -O2 execution
test
Product: gcc
Version: 13.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: testsuite
Assignee: unassigned at gcc dot gnu.org
Reporter: rguenth at gcc dot gnu.org
Target Milestone: ---
I see this testcase FAILing because it ends up returning uninitialized memory.
This can be seen when enabling glibc malloc perturbing. The 'off' method
ands with zero to avoid this.
int
__attribute__ ((noinline))
dyn (int size, int i)
{
__builtin_printf ("dyn\n");
fflush (stdout);
int *alloc = __builtin_calloc (size, sizeof (int));
int ret = alloc[i];
__builtin_free (alloc);
return ret;
}
...
int
main (void)
{
int ret = dyn (2, 2);
ret |= off (4, 4, 0);
return ret;