> On Aug 3, 2023, at 12:15 PM, Siddhesh Poyarekar <siddh...@gotplt.org> wrote:
>
> On 2023-08-02 10:02, Qing Zhao wrote:
>> /*when checking the observed access p->array, we only have info on the
>> observed access, i.e, the TYPE_SIZE info from the access. We don't have
>> info on the whole object. */
>> expect(__builtin_dynamic_object_size(q->array, 1), q->foo * sizeof(int));
>> expect(__builtin_dynamic_object_size(q->array, 0), -1);
>> expect(__builtin_dynamic_object_size(q->array, 3), q->foo * sizeof(int));
>> expect(__builtin_dynamic_object_size(q->array, 2), 0);
>> /*when checking the pointer p, we have no observed allocation nor observed
>> access.
>> therefore, we cannot determine the size info here. */
>> expect(__builtin_dynamic_object_size(q, 1), -1);
>> expect(__builtin_dynamic_object_size(q, 0), -1);
>> expect(__builtin_dynamic_object_size(q, 3), 0);
>> expect(__builtin_dynamic_object_size(q, 2), 0);
>
> I'm wondering if we could sizeof (*q) + q->foo for __bdos(q, 0), but I
> suppose it could mean generating code that potentially dereferences an
> invalid pointer.
I think for __bdos(q, 0), if there is no allocation information for q, we
cannot decide the size for its pointee.
> Surely we could emit that for __bdos(q->array, 0) though, couldn't we?
For __bdos(q->array, 0), we only have the access info for the sub-object
q->array, we can surely decide the size of the sub-object q->array, but we
still cannot
decide the whole object that is pointed by q (the same reason as above), right?
Qing
>
> Thanks,
> Sid