Boost logo

Boost :

Subject: Re: [boost] [exception] Unreachable returns (was [log] Comments)
From: Daniel James (dnljms_at_[hidden])
Date: 2010-03-17 04:25:09


On 17 March 2010 03:23, Emil Dotchevski <emildotchevski_at_[hidden]> wrote:
> On Tue, Mar 16, 2010 at 5:41 PM, Daniel James <dnljms_at_[hidden]> wrote:
>> It would be nice to have a proper solution in
>> Boost.Exception, or maybe there already is one and I missed it?
>
> I am not sure what you mean by "proper", I just fix warnings when
> users report them. So if there is no warning it's all good, right?

But this isn't a warning in your code so you can't fix them, you
should supply the tool for others to fix them in their code. And the
only reason there isn't a warning is because I used a fragile hack
(it's fragile because it depends on undocumented knowledge of the
implementation of Boost.Exception, so if you change it in the future,
it'll break).

The problem is functions like this:

    int foo() {
        boost::throw_exception(my_exception());
    }

This causes a compiler (I think it was Sun) to issue a 'no return
statement' error, so it's changed to:

    int foo() {
        boost::throw_exception(my_exception());
        return 0;
    }

That fixes the error, but now there's a Visual C++ warning about
unreachable code.

Daniel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk