Community
Participate
Working Groups
Hi there. I have been experiencing problems with the code formatter in this new version of Eclipse CDT (8.0, build ID 20110615-0604). These problems do not occur in the previous version of Eclipse CDT (7.0.2). In order to reproduce the problem, just create a new C++ project and create a single CPP file as follows: #include <iostream> using namespace std; long function() { cout << "From function" << endl; } class Foo { public: Foo(); ~Foo(); void SayHello() const; }; int main() { Foo * foo = new Foo(); int i = static_cast<int>(5); foo->SayHello(); return 0; } If you select the BSD/Allman built-in formatting profile and format the code above, everything is fine, and it is displayed just as I just showed you. However, if we change the expression inside the static_cast to a call to 'function()', the line right after it gets messed up, and we get: int main() { Foo * foo = new Foo(); int i = static_cast<int>(function()); foo ->SayHello(); return 0; } This problem also occurs if the expression inside the static_cast is an arithmetic operation, such as '5 * 6' or '4 + 5'. I tried to copy and paste the static_cast all over the main() function, and it seems that only the line right after it gets corrupted. Everything afterwards is properly formatted. Looks like the problem arises when whatever is inside the static_cast is different from a simple identifier or constant.
Fixed in master and 8.0.1.
*** cdt git genie on behalf of Anton Leherbauer *** Bug 353974 - Formatting C code does not work for certain uses of static_cast [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=1f9bdc3019479026fd2ec641eda001e7072910fe
*** cdt git genie on behalf of Anton Leherbauer *** Bug 353974 - Formatting C code does not work for certain uses of static_cast [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=35a5ad9dbbd9083cfa190fcdaff2a9c07ffa5358
*** Bug 356682 has been marked as a duplicate of this bug. ***