Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-12-04 10:07:48


Gennaro Prota <gennaro_prota_at_[hidden]> writes:

> On Tue, 03 Dec 2002 20:55:02 -0500, David Abrahams
> <dave_at_[hidden]> wrote:
>
>>
>>I'd like a macro to detect that a compiler requires a return value
>>even when no paths return from a function. Example:
>>
>> int f()
>> {
>> throw "hello";
>> };
>>
>>If this fails to compile, we may need to add a dummy "return 0;" at
>>the end.
>
> I'm a little surprised by this question. Are you saying that *no*
> paths return a value and you declare the function as non void?

Yes. Actually I was wrong about aCC; it only warns. Still annoying, though.

> Maybe you were referring to a situation like this?
>
>
> // The throw is conditional, and there's at
> // least one path that does return a value
> //
> template <typename ExceptionT>
> void do_throw(ExceptionT const & ex) { throw ex; }
>
>
> int f() {
> for ( ...)
> if (...)
> return somevalue;
>
> do_throw( some_exception() );
> }

No. There are several instances like the one I cited in our test suite
(the function lib, I think).

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

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