Bug 425434 - Changing behavior when renaming variable to a pointer
Summary: Changing behavior when renaming variable to a pointer
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: Next   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-10 12:52 EST by Gustavo Wagner CLA
Modified: 2020-09-04 15:17 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 Gustavo Wagner CLA 2014-01-10 12:52:00 EST
Eclipse IDE for C/C++ Developers
Version: Kepler Service Release 1
Build id: 20130919-0819


Reproducing the bug:


Consider the following code:
======== Original Version ========
int main(int a, char** argv) {
    int b = 0; // Variable to be renamed
    return b;
}
==================================

The refactoring tool is allowing to rename the variable "b" to an invalid identifier (in the following case, a pointer):

========== Refactored ===========
int main(int a, char** argv) {
    int *b = 0; // Invalid rename!
    return *b;
}
=================================

Notice that when compiling the resulting program (Refactored), the compiler issues a warning (since I'm returning a pointer instead of an integer). When attempting to execute the refactored version, a Segmentation Fault is thrown.

Maybe it would be better to check the rules of a well-formed identifier before applying the transformation to avoid this kind of problem.


Thanks in advance.