Skip to content

Propagate bounds information from constant arrays #276

@Machiry

Description

@Machiry

For the following example:

typedef unsigned long size_t;
_Itype_for_any(T) void *malloc(size_t size) : itype(_Array_ptr<T>) byte_count(size);
struct foo {
  int *f;
  int n;
};

void bar(struct foo *p) {
  int arr[100];
  p->f = arr;
  p->f[0] = 0;
  p->n = 100;
}

As of now, we fail to find bound for f.

Expected output:

typedef unsigned long size_t;
_Itype_for_any(T) void *malloc(size_t size) : itype(_Array_ptr<T>) byte_count(size);
struct foo {
  _Array_ptr<int> f : count(n);
  int n;
};

void bar(_Ptr<struct foo> p) {
  int arr _Checked[100];
  p->f = arr;
  p->f[0] = 0;
  p->n = 100;
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions