Opened 4 years ago

Closed 4 years ago

#51 closed defect (fixed)

Reference assignment allows pointer conversions

Reported by: Rob Schluntz Owned by: Rob Schluntz
Priority: major Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

forall( dtype T | sized(T) ) T * foo( void ) {
    printf( "foo1\n" );
    return (T *)0;
}
forall( dtype T | sized(T) ) T & foo( void ) {
    printf( "foo2\n" );
    return (T &)*(T *)0;
}
int main( void ) {
    int * i = foo(); // correctly calls foo1
    int & j = foo(); // correctly calls foo2

    i = foo();  // incorrectly calls foo2 instead of foo1
    printf( "fred\n" ); // never gets here
    &j = foo();  // correctly calls foo2
}

The call i = foo() incorrectly attempts to convert i to void *.

Change History (1)

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

Resolution: fixed
Status: assignedclosed

In cdbfab0:

Remove unsafe void * constructors and assignment operators from prelude [closes #24] [fixes #51]

Note: See TracTickets for help on using tickets.