Bug 396357 - Extract Function incorrectly extracts va_start
Summary: Extract Function incorrectly extracts va_start
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 18:01 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:24 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 18:01:02 EST
In the following program...
==========
#include <stdarg.h>
 void gmp_sscanf (va_list args, const char *fmt, ...){
 va_start(args, fmt); //extract
 }
int main() {
 va_list args;
 const char *fmt;
 gmp_sscanf(args,fmt);
 return 0;
}
==========

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

==========
#include <stdarg.h>

void extracted_function(va_list args, const char* fmt) {
	va_start(args, fmt);
}

void gmp_sscanf(va_list args, const char *fmt, ...) {
	extracted_function(args, fmt);
 }
int main() {
 va_list args;
 const char *fmt;
 gmp_sscanf(args,fmt);
 return 0;
}
==========

va_start can only be used in a varargs function.