Bug 399212 - Extract Constant incorrectly extracts a string literal
Summary: Extract Constant incorrectly extracts a string literal
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.2   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: 2013-01-27 17:58 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:22 EDT (History)
2 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 2013-01-27 17:58:31 EST
In the following program...
==========
int main()
{
	static char msg[] = "Error"; // select "Error"
	return 0;
}
==========

If you select "Error" (on line 3), and invoke the Extract Constant refactoring, CDT produces the following incorrect code:

==========
int main()
{
	const char* extracted_constant = "Error";
	static char msg[] = extracted_constant; // select "Error"
	return 0;
}
==========

The extracted variable is of type const char*. So, it cannot be an initializer for static char msg[].