|
Boost : |
Subject: Re: [boost] Mark throw_exception as noreturn?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-07-05 01:33:06
On Sat, Jul 4, 2009 at 6:11 PM, Mathias
Gaunard<mathias.gaunard_at_[hidden]> wrote:
> Andrey Semashev wrote:
>
>> I was wondering why the throw_exception function is not marked as
>> noreturn? This makes it troublesome to use it as a drop-in replacement
>> for throw statements as it starts to flag compiler warnings about
>> missing return statements in non-void functions.
>>
>> I suggest to mark the function as noreturn at least for compilers that
>> support it. GCC has __attribute__((noreturn)), MSVC has
>> __declspec(noreturn).
>
> Why is throw_exception detected as returning something in the first place?
>
> I've personally tried to force __attribute__((noreturn)) with GCC, but it
> doesn't work, it says the function does return.
>
> Looking at the code though, I can't tell what is wrong with it.
> A fix to that would be appreciated. Without that, I'd personally rather not
> use throw_exception.
I've added a macro BOOST_ATTRIBUTE_NORETURN. The problem is fixed for
MSVC, feel free to add support for other compilers in
boost/exception/detail/attribute_noreturn.hpp.
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk