|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Mark throw_exception as noreturn?Hi,
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). _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
|
|
Re: Mark throw_exception as noreturn?Andrey Semashev wrote:
> Hi, > > I was wondering why the throw_exception function is not marked as > noreturn? I don't know. That could be because not all compilers support that annotation (but then, that's not usually something which scares Boost off). > 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). I don't know what they guys here want to do, or whether there's an accepted solution to this. For the immediate needs, however, you could use BOOST_UNREACHABLE_RETURN in the calling function. -- Genny _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
|
|
Re: Mark throw_exception as noreturn?Gennaro Prota wrote:
> For the immediate needs, however, > you could use BOOST_UNREACHABLE_RETURN in the calling function. >From what I see from Boost.Config headers, the macro unfolds to something non-empty only for three compilers, and GCC is not among them. I encountered the problem with GCC. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
|
|
Re: Mark throw_exception as noreturn?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. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
|
|
Re: Mark throw_exception as noreturn?On Sat, Jul 4, 2009 at 6:11 PM, Mathias
Gaunard<mathias.gaunard@...> 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 _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
|
|
Re: Mark throw_exception as noreturn?Emil Dotchevski wrote:
> 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. Should it really be part of Boost.Exception (moreover, private part)? Maybe it's better to be in Boost.Config? _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
|
|
Re: Mark throw_exception as noreturn?On Sun, Jul 5, 2009 at 2:13 AM, Andrey
Semashev<andrey.semashev@...> wrote: > Emil Dotchevski wrote: > >> 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. > > Should it really be part of Boost.Exception (moreover, private part)? Maybe > it's better to be in Boost.Config? Probably the correct place is Boost.Config, but so far boost::throw_exception (which is part of Boost Exception) seems to be the only function that needs this macro and I thought we don't have good enough reason to add weight to Boost.Config at this point. It'll take no time at all to make BOOST_ATTRIBUTE_NORETURN official if it is needed elsewhere in the future. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost |
| Free embeddable forum powered by Nabble | Forum Help |