Subject: Re: [Boost-bugs] [Boost C++ Libraries] #4282: Please add BOOST_ATTRIBUTE_NORETURN to rethrow_exception()
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-06-08 16:06:35
#4282: Please add BOOST_ATTRIBUTE_NORETURN to rethrow_exception()
---------------------------------------------------+------------------------
Reporter: Gevorg Voskanyan <v_gevorg@â¦> | Owner: emildotchevski
Type: Feature Requests | Status: new
Milestone: | Component: exception
Version: Boost 1.43.0 | Severity: Cosmetic
Keywords: |
---------------------------------------------------+------------------------
Comment(by Gevorg Voskanyan <v_gevorg@â¦>):
No, I didn't make a patch as simple addition of BOOST_ATTRIBUTE_NORETURN
to rethrow_exception was all was thinking of. That worked for me with
msvc8 and didn't produce any warnings with /W4. After seeing your comment
I tried the same with gcc 4.4.0 and indeed it gave me the same "'noreturn'
function does return" warning. What is most annoying to me is that gcc
gives such warnings even though there is a #pragma GCC system_header at
the top of the header file. So I then tried adding a
throw "convince the compiler this function doesn't return";
line after p->rethrow(); in rethrow_exception(), which made that warning
to go away. With both BOOST_ATTRIBUTE_NORETURN and a dummy throw statement
present, both msvc and gcc happily compile code without warnings they were
previously complaining about. However I am not sure if that is an
acceptable solution.
Or maybe add BOOST_ATTRIBUTE_NORETURN only for msvc as the problem is more
severe with msvc than with gcc? I don't know.
To be explicit, here's why I think this is more a problem with msvc than
gcc. The following code
{{{
int f( boost::exception_ptr p )
{
boost::rethrow_exception( p );
}
}}}
is rejected by msvc with an error saying that f must return a value,
whereas gcc merely gives a "control reaches end of non-void function"
warning.
Thanks for looking into this,
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4282#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC