Community
Participate
Working Groups
Build Identifier: 20110526-1053 I get on the following code the wrong warning "No return, in function returning non-void" Reproducible: Always Steps to Reproduce: int main() { try { return 3; } catch (...) { return 2; } }
Created attachment 200544 [details] Fix and tests 2 distinct issues were here: - CFG didn't handle catch(...) correctly, - the checker didn't consider the try block statement a compound statement (the same goes for range based for statement from c++0x, also fixed) BTW: The patch fixes the checker but the CFG View can't display the graph for the code from summary. However, it displays correct CFG when you wrap all the function body in a `if (1)` condition or something. Alena, could you have a look on this?
I have this issue in both CDT 8.0 and current trunk (Build id: 20111215-0110). Getting this fix applied for M5 or M6 would be great. Let me know if any testing would help. It's great that many of the issues I'm having already have fixes in progress :)
The following code also triggers the warning: int test2_f(); int test1_f() { while (1) { if (test2_f()) { return 1; } } } This is in the juno release.
I have the same problem with this on Juno/CDT 8.1.1: int foo() { try { return 1; } catch (std::runtime_error& ex) { throw; } } Is this case addressed by the submitted patch? When do we think the fix will be merged? The bug still shows as NEW 16 months after reported and fixed?
*** Bug 355938 has been marked as a duplicate of this bug. ***
(In reply to comment #1) > BTW: > The patch fixes the checker but the CFG View can't display the graph for the > code from summary. However, it displays correct CFG when you wrap all the > function body in a `if (1)` condition or something. > Alena, could you have a look on this? This doesn't seem related to the fix since this sample code also has the same problem: int foo(int a) { if(a) { return 1; } else { return 1; } } ViewContentProvider.getFlat calls getMergeNode().getOutgoing() which returns null.
Patch applied to 8_1 and master with minor modifications. Thank you! http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=660a75531a7fab3095eabb2fc8e0de5250a30916
The test case in comment 3 is a different issue. I filed it at https://bugs.eclipse.org/bugs/show_bug.cgi?id=394521.
(In reply to comment #4) > Is this case addressed by the submitted patch? Yes.
*** cdt git genie on behalf of Tomasz Wesolowski *** Bug 348387 - fp in ReturnChecker using try/catch [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=660a75531a7fab3095eabb2fc8e0de5250a30916
*** cdt git genie on behalf of Tomasz Wesolowski *** Bug 348387 - fp in ReturnChecker using try/catch [*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=5e369d662ebc55256faf14dc8b0998a898d4e85f
*** Bug 368261 has been marked as a duplicate of this bug. ***