Opened 7 years ago

Closed 7 years ago

#55 closed defect (fixed)

intrusive stack crash

Reported by: Thierry Delisle Owned by: Rob Schluntz <rschlunt@…>
Priority: major Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

This code crashes the compiler :

#define NULL (void*)0

trait is_node(dtype T) {
	T*& get_next( T& );
};

forall(dtype T | is_node(T))
struct __stack {
	T * top;
};

forall(dtype T | is_node(T))
void ?{}( __stack(T) & this ) {
	this.top = NULL;
}

forall(dtype T | is_node(T) | sized(T))
void push( __stack(T) & this, T * val ) {
	get_next( *val ) = this.top;
	this.top = val;
}

forall(dtype T | is_node(T) | sized(T))
T * pop( __stack(T) & this ) {
	T * top = this.top;
	if( top ) {
		this.top = get_next( *top );
		get_next( *top ) = NULL;
	}
	return top;
}

struct node;
static inline node *& get_next( node & this );
__stack(node) n;

struct node {
	node * next;
};

static inline node *& get_next( node & this ) { return this.next; }

Change History (1)

comment:1 Changed 7 years ago by Rob Schluntz <rschlunt@…>

Owner: set to Rob Schluntz <rschlunt@…>
Resolution: fixed
Status: newclosed

In 760ba67:

Temporarily remove type parameter delete for dtype-static generics [fixes #55]

Note: See TracTickets for help on using tickets.