Opened 12 months ago

Last modified 8 months ago

#195 new defect

Unnecessary dereference leads to segfault [from ticket #70]

Reported by: Thierry Delisle Owned by:
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;
    int & j;

    i = foo();  // correctly calls foo1
    &j = foo();  // incorrectly calls foo1 instead of foo2
}

This leads to a segfault from a null ptr that should never be dereferenced

Change History (1)

comment:1 Changed 8 months ago by mlbrooks

The description on this ticket is a little confusing and possibly out of date. If the behaviour did change in the last couple months, that could be relevant to an issue I'm currently facing.

Description seems to be stating two issues

  • that the foo2 body is doomed to crash when run
  • that the resolution of a call to foo1 v foo2 is wrong

A current repro attempt got this behaviour, which is not what the ticket description says:

    i = foo();   // calls foo2, which crashes
    &j = foo();  // never reached
Last edited 8 months ago by mlbrooks (previous) (diff)
Note: See TracTickets for help on using tickets.