Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356908

Summary: false "No return ..." positive if statement following a throw
Product: [Tools] CDT Reporter: Jens Elmenthaler <jens.elmenthaler>
Component: cdt-codanAssignee: CDT Codan Inbox <cdt-codan-inbox>
Status: CLOSED DUPLICATE QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug, yevshif, zeratul976
Version: 8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Jens Elmenthaler CLA 2011-09-07 06:32:00 EDT
Build Identifier: HEAD

In the following code, a false positive for "No return, in function returning non-void" is reported:

int testReturnChecker()
{
  throw 42;
  ;
}


Reproducible: Always

Steps to Reproduce:
This example may seem stupid at a first glance. However consider an application where you want to log each thrown exception. We do it by defining a macro like this

#defing MY_THROW(_e, _txt_expr) { \
  stringstream buffer; \
  buffer << _txt_expr; \
  log(_e, buffer.str(), __FILE__, __LINE__); \
  throw _e; \
}

For readability reasons, the caller should be able to terminate the call to MY_THROW with a trailing semicolon:

MY_THROW(e);
Comment 1 Nathan Ridge CLA 2013-07-21 19:10:21 EDT
Duplicate of bug 348386.
Comment 2 Nathan Ridge CLA 2016-12-22 18:49:18 EST

*** This bug has been marked as a duplicate of bug 348386 ***