Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356908 - false "No return ..." positive if statement following a throw
Summary: false "No return ..." positive if statement following a throw
Status: CLOSED DUPLICATE of bug 348386
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: CDT Codan Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-07 06:32 EDT by Jens Elmenthaler CLA
Modified: 2016-12-22 18:49 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***