Skip to content

Spurious warning due to wrong array size from calloc #1766

@Robotechnic

Description

@Robotechnic

I just found out that this program:

#include <assert.h>
#include <stdlib.h>

int main() {
	int *buff = calloc(50, sizeof(int));
	if (buff == NULL) {
		return 1;
	}
	return buff[5];
}

Causes goblint to raise an error while it shouldn't. I get:

[Error][Behavior > Undefined > ArrayOutOfBounds > PastEnd] Must access array past end

It has been mentioned in #702 and #135, but this is not really a precision problem.

Changing the array size to the number of items and the blob size to the size of each item seems to fix the issue with this particular problem. However, it breaks soundness, so it isn't a suitable solution.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions