Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349249 - [fp] undeserved warning about returning from non-void when delegating to an always-throw function
Summary: [fp] undeserved warning about returning from non-void when delegating to an a...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 8.2   Edit
Assignee: Sergey Prigogin CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-13 18:01 EDT by Matt Hargett CLA
Modified: 2013-08-24 21:11 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Hargett CLA 2011-06-13 18:01:53 EDT
Build Identifier: 201106081058

the code below yields a false positive for "No return, in function returning non-void" for the get_for_update() method:


void throw_is_immutable(const int val);


int	get_for_update(void)
{
	throw_is_immutable();
}

void
throw_is_immutable(void)
{
	throw;
}


Reproducible: Always
Comment 1 Tomasz Wesolowski CLA 2011-06-21 07:55:58 EDT
So does GCC 4.5 :)

It could be the case that similarly to as explained in bug 346557, we should prefer to use attributes for that (that is, GCC's __attribute__ ((noreturn)) or C++0x's [[noreturn]] ). Might be worth a discussion.
Comment 2 Andrew Eidsness CLA 2011-06-23 12:28:16 EDT
I get the same warning in a simpler case:

std::string As_String( int i )
{
  try
    {
      return strs[type];
    }
  catch(...)
    {
      return as_string( type );
    }
}
Comment 3 Mario Charest CLA 2011-08-23 18:23:32 EDT
Even simpler ;-)

int CTraceError ()
{

   try
   {
      return 0;
   }
   catch (...)
   {
      return 1;
   }
}
Comment 4 Nathan Ridge CLA 2013-08-24 17:20:17 EDT
The examples in comment 2 and comment 3 are duplicates of bug 348387, which has been fixed.

Regarding the example in comment 0, we don't warn if the function is marked __attribute__((noreturn)). This matches the behaviour of GCC.

I think this bug can be closed.
Comment 5 Sergey Prigogin CLA 2013-08-24 21:11:21 EDT
This was fixed a while ago.