Community
Participate
Working Groups
Version: Juno Service Release 1 Build id: 20120920-0800 CDT refactoring allows to extract local variable with a name of an existent global variable, leading to a behavioral change. Reproducible: Always Steps to Reproduce: 1. Create a C file with the following code: #include <stdio.h> int y = 20; int main(){ int x = 10; //extract local variable printf("%d", y); return 0; } //output: 20 2. Select "10" literal and apply the Extract Local Variable refactoring typing "y" in the Variable Name (CDT silently do that): #include <stdio.h> int main(){ int y = 10; int x = y; printf("%d", y); return 0; } //output: 10 3. The program change its output from 20 to 10.
Created attachment 226587 [details] Minimal project to verify the problem I've verified (a slightly modified version of) this using eclipse-SDK-N20130203-2000-win32 with org.eclipse.cdt_8.2.0.201212170456 . Here's the project, to make it easier for other people to verify it. In order to avoid the need for an #include, I changed the code to: int y = 20; int main(){ int x = 10; //extract local variable return y; } The problem still shows up in the same way.