Opened 16 years ago

Closed 16 years ago

#224 closed defect (invalid)

Free fails when used on a struct pointer.

Reported by: dfix Owned by:
Priority: major Milestone: Release 1.0
Component: examples Version: 1.0
Keywords: pointer, free, dealocate, dealocation, record Cc:

Description

This works in C, but it's being seen here as an invalid pointer. It seems that free has only been implemented for arrays.

typedef struct Node{

	struct Node* next;
	int value;

} Node;

void main () {
	
	Node u1;
	Node *a;
	
	a = &u1;

 	free(a); 
}

edu.udel.cis.vsl.tass.util.ExecutionException: Execution error encountered at linkedListDeletion.mmp 16.7--16.8: "a"
Invalid pointer:
&u1

Change History (1)

comment:1 by Stephen Siegel, 16 years ago

Resolution: invalid
Status: newclosed

"free" is only applicable to objects allocated by an earlier call to "malloc" (in C as well as TASS). There is no need to deallocate an object allocated on the stack---the object goes away when the function is popped from the stack. Free and malloc are for heap-allocated data.

In fact this would be a problem if TASS did not report an error, so if it fails to report an error in the case of an array, please post a similar ticket for that case.

Note: See TracTickets for help on using tickets.