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)
Change History (10)
by , 15 years ago
Attachment: | lexical_cast_warning.patch added |
---|
follow-up: 2 comment:1 by , 15 years ago
comment:2 by , 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 , 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 , 14 years ago
Attachment: | lexical_cast.patch added |
---|
comment:4 by , 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 , 13 years ago
Attachment: | lexical_cast2.patch added |
---|
comment:5 by , 13 years ago
Milestone: | To Be Determined → Boost 1.40.0 |
---|---|
Version: | Boost 1.35.0 → Boost Development Trunk |
comment:6 by , 13 years ago
Milestone: | Boost 1.40.0 → Boost 1.41.0 |
---|
comment:7 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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) {
}
and then
throw_exception_impl<Target>(bad_lexical_cast(typeid(Source), typeid(Target)));
-- Alex