Boost logo

Boost :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2004-12-15 16:40:42


On Dec 6, 2004, at 6:03 PM, David Abrahams wrote:

> Sean Parent wrote:
>> On Dec 6, 2004, at 2:02 PM, Peter Dimov wrote:
>>>
>>> I get warning C4172 from VC++ 7.1, "returning address of local
>>> variable or temporary", on this example (in
>>> function_template.hpp:111).
>>>
>> In CodeWarrior 9.3 BOOST_NO_VOID_RETURNS is not defined so in
>> function.hpp the code falls into the static_cast<> case
>> -----
>> # ifndef BOOST_NO_VOID_RETURNS
>> return static_cast<result_type>(result);
>> # else
>> return result;
>> # endif // BOOST_NO_VOID_RETURNS
>
> [Thanks for posting to the list, Sean -- this is a Boost.Function
> question so you should indicate it in the subject line]
>
> ?? That doesn't look like a very good way to be using
> BOOST_NO_VOID_RETURNS. What's going on here?

The static_cast<result_type> ensures that when result_type == void, the
"return" doesn't need to disappear. It's essentially a workaround to a
workaround for BOOST_NO_VOID_RETURNS. Anyway, it should be fixed now.

        Doug


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