Bug 396340 - Extract Function omits return type
Summary: Extract Function omits return type
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.1.1   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-11 17:25 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:23 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Farnaz Behrang CLA 2012-12-11 17:25:48 EST
In the following program...

==========
void func(long long int num) {
	num++; //extract
	printf("%llu",num);
	}
int main(){
	long long int num=8223372036854775807;
	func(num);
	return 0;
}
==========

...if you select line 2 and invoke the Extract Function refactoring, CDT produces the following code:

==========
extracted_function(long long int num) {
	num++; //extract
	return num;
}

void func(long long int num) {
	num = extracted_function(num);
	printf("%llu",num);
	}
int main(){
	long long int num=8223372036854775807;
	func(num);
	return 0;
}
==========

There is not any return type for the extracted function while the expected return type should be long long int. The result in this case is 1486618624 but we expect that to be 8223372036854775808. So, I would expect the extraction would be as follows:

==========
long long int extracted_function(long long int num) {
	num++; //extract
	return num;
}

void func(long long int num) {
	num = extracted_function(num);
	printf("%llu",num);
	}
int main(){
	long long int num=8223372036854775807;
	func(num);
	return 0;
}
==========