Opened 12 years ago

Closed 12 years ago

#4282 closed Feature Requests (fixed)

Please add BOOST_ATTRIBUTE_NORETURN to rethrow_exception()

Reported by: Gevorg Voskanyan <v_gevorg@…> Owned by: Emil Dotchevski
Milestone: Component: exception
Version: Boost 1.43.0 Severity: Cosmetic
Keywords: Cc: v_gevorg@… Christopher Schmidt

Description

That will make some compilers happier. Thank you.

Change History (3)

comment:1 by Steven Watanabe, 12 years ago

Do you have a patch? Adding BOOST_ATTRIBUTE_NORETURN gives this warning instead:

boost/exception/detail/exception_ptr.hpp: In function 'void boost::rethrow_exception(const boost::exception_ptr&)':
boost/exception/detail/exception_ptr.hpp:391: warning: 'noreturn' function does return

I can't seem to get rid of this. Adding BOOST_ATTRIBUTE_NORETURN to clone_base::rethrow doesn't help.

comment:2 by Gevorg Voskanyan <v_gevorg@…>, 12 years ago

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,

comment:3 by Emil Dotchevski, 12 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.