Opened 3 years ago

#202 new defect

Type manipulation in long chains of post-fix functions

Reported by: m3zulfiq Owned by:
Priority: major Component: cfa-cc
Version: 1.0 Keywords: postfix, type, polymorphic, function
Cc:

Description

In the code below, ndp1 initialization goes to the wrong polymorphic version of function xalloc. Although, nip1 and ndp0 initializations work fine.
The only difference between ndp0 and ndp1 is the length of the chain of postfix functions.

forall( dtype T | sized(T) ) {

struct S1 { T * oaddr; bool copy;};

T * ?`post_2(S1(T) in) { return (T*)0p; }
S1(T) ?`post_1(S1(T) in) { return (S1(T)){(T*)in.oaddr}; }
S1(T) ?`xalloc (T * in) { printf("TT "); return (S1(T)){(T*)in}; }

forall( dtype S | sized(S) ) {

S1(T) ?`xalloc (S * in) { printf("TS "); return (S1(T)){(T*)in}; }

}

}

int main() {

int * ip = malloc(4);
int * nip0 = ipxallocpost_2; prints TT
int * nip1 = ipxallocpost_1`post_2;
prints TT
double * ndp0 = ipxallocpost_2; prints TS
double * ndp1 = ipxallocpost_1`post_2;
prints TT but should TS
return 0;

}

Change History (0)

Note: See TracTickets for help on using tickets.