| Summary: | [fp] undeserved warning about returning from non-void when delegating to an always-throw function | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Matt Hargett <matt> |
| Component: | cdt-codan | Assignee: | Sergey Prigogin <eclipse.sprigogin> |
| Status: | RESOLVED FIXED | QA Contact: | Elena Laskavaia <elaskavaia.cdt> |
| Severity: | normal | ||
| Priority: | P3 | CC: | cdtdoug, eclipse.sprigogin, eclipse, kosashi, mcharest, yevshif, zeratul976 |
| Version: | 8.0 | ||
| Target Milestone: | 8.2 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
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. I get the same warning in a simpler case:
std::string As_String( int i )
{
try
{
return strs[type];
}
catch(...)
{
return as_string( type );
}
}
Even simpler ;-)
int CTraceError ()
{
try
{
return 0;
}
catch (...)
{
return 1;
}
}
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. This was fixed a while ago. |
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