Euphoria Ticket #146: Refcounting incorrect for temps passed in default calls

When a temp is created in a call to a routine that uses the temp/parameter as a parameter to assign the default value to another parameter, the temp is prematurely cleaned up.

include std/unittest.e 
 
function bar( object x ) 
  return 0 
end function 
 
function foo( object x, integer y = bar(x) ) 
  return sequence(x) 
end function 
 
test_equal( "temp with delete routine lost when used in default argument as an argument to another call",  
  1, foo( repeat( 0, 2 ) ) )  
 
test_report() 

Details

Type: Bug Report Severity: Major Category: Translator
Assigned To: mattlewis Status: Fixed Reported Release: r3131
Fixed in SVN #: 3133, 3132 View VCS: 3133, 3132 Milestone:

1. Comment by SDPringle Apr 02, 2010

So in this example will y in foo() be cleaned up prematurely?

This program doesn't demonstrate a failure on v3127. eutest reports 100% success for me. Perhaps, you could use a different example?

2. Comment by mattlewis Apr 03, 2010

The translator now assigns those temps to another temp and increments the refcount. The new temp is passed to the function in the default parameter code.

Search



Quick Links

User menu

Not signed in.

Misc Menu