Euphoria
Ticket #146:
Refcounting incorrect for temps passed in default calls
-
Reported by
mattlewis
Apr 02, 2010
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
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.