https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116983
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Plus the useless pointer conversions in GIMPLE can mean that
void *foo (int);
struct counted {
int counter;
int array[] __attribute__((counted_by(counter)));
};
struct notcounted {
int counter;
int array[];
};
int
bar (int x)
{
void *p = foo (x);
if (x & 1)
{
struct counted *q = (struct counted *) p;
use (q);
return __builtin_dynamic_object_size (q, 0);
}
else
{
struct notcounted *r = (struct notcounted *) p;
use2 (r);
return __builtin_dynamic_object_size (r, 0);
}
}
with CSE/SCCVN whether one gets actually struct counted * or struct notcounted
* or void * pointer type is a lottery.