Opened 15 years ago

Closed 13 years ago

#1791 closed Patches (fixed)

fix warning on MSVC warning level 4

Reported by: Stephan Owned by: nasonov
Milestone: Boost 1.41.0 Component: lexical_cast
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

Attached patch fixes a warning in MSVC 8 on warning level 4 by removing a return statement after a throw "call"

Attachments (3)

lexical_cast_warning.patch (431 bytes ) - added by Stephan 15 years ago.
lexical_cast.patch (822 bytes ) - added by Richard Webb <richard.webb@…> 14 years ago.
lexical_cast2.patch (768 bytes ) - added by Richard Webb <richard.webb@…> 13 years ago.

Download all attachments as: .zip

Change History (10)

by Stephan, 15 years ago

Attachment: lexical_cast_warning.patch added

comment:1 by nasonov, 15 years ago

As you may guess, the return statement was added to supress a warning.

Can you please discusss possible workarounds on boost-devel? I don't have time, sorry.

Off the top of my head:

template<class R, class E> R throw_exception_impl(E const & e) {

throw_exception(e);

I expect a lot of workarounds around this place return R();

}

and then

throw_exception_impl<Target>(bad_lexical_cast(typeid(Source), typeid(Target)));

-- Alex

in reply to:  1 comment:2 by Stephan, 14 years ago

Replying to nasonov:

As you may guess, the return statement was added to supress a warning.

Can you please discusss possible workarounds on boost-devel? I don't have time, sorry.

Sure: Here is what Paul came up with:

#if (defined _MSC_VER)
# pragma warning( push )
# pragma warning( disable : 4702 ) : unreachable code
#endif

throw_exception(bad_lexical_cast(typeid(Source), typeid(Target)));
return Target(); // normally never reached (throw_exception)

#if (defined _MSC_VER)
# pragma warning( pop )
#endif

which looks fine for me.

Thanks,

Stephan

comment:3 by Richard Webb <richard.webb@…>, 14 years ago

Attached is a patch that pragmas out this warning, silencing the warnings that i see on VC9.

The patch is slightly different to the previously suggested patch, in that (on VC9 at least), the pragma has to surround the whole function rather than just the return line in order to actually silence the warning.

by Richard Webb <richard.webb@…>, 14 years ago

Attachment: lexical_cast.patch added

comment:4 by sdiederich, 14 years ago

Ping. Warning is not yet patched in trunk, or release branch, and was therefore not in 1.37. Richard's patch looks good to me. Any chance we can see this included in 1.38?

by Richard Webb <richard.webb@…>, 13 years ago

Attachment: lexical_cast2.patch added

comment:5 by Richard Webb <richard.webb@…>, 13 years ago

Milestone: To Be DeterminedBoost 1.40.0
Version: Boost 1.35.0Boost Development Trunk

comment:6 by nasonov, 13 years ago

Milestone: Boost 1.40.0Boost 1.41.0

comment:7 by nasonov, 13 years ago

Resolution: fixed
Status: newclosed

(In [56158]) Fix #1791 (fix warning on MSVC warning level 4) and undo r34801 (some "rewording" to avoid spurious level 4 warnings with VC7.1 and VC8).

Note: See TracTickets for help on using tickets.