[1.35][lexical_cast][concept check][range] Build error and warnings with MSVC8 on Warning Level 4

As we tried to update to 1.35 today, we found some warnings with MSVC on Warning Level 4 in: lexical_cast: There was a return statement after a call to throw_exception which causes a unreachable code warning. I can see no problem by just removing that return. see http://svn.boost.org/trac/boost/ticket/1791 concept_check: BOOST_concept(SGIAssignable,(TT)) causes two warnings: C4510: default constructor could not be generated C4610: object 'class' can never be instantiated - user-defined constructor required solved thorugh pragmas see http://svn.boost.org/trac/boost/ticket/1792 and an error in range/iterator_range: see http://svn.boost.org/trac/boost/ticket/1793 for details. The patch is attached, as I was not able to discuss with Akismet that it's no spam ;) "Submission rejected as potential spam (Akismet says content is spam)" cheers, stephan

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Stephan Diederich Sent: 08 April 2008 20:53 To: boost@lists.boost.org Subject: [boost] [1.35][lexical_cast][concept check][range] Build error andwarnings with MSVC8 on Warning Level 4
As we tried to update to 1.35 today, we found some warnings with MSVC on Warning Level 4 in:
lexical_cast: There was a return statement after a call to throw_exception which causes a unreachable code warning. I can see no problem by just removing that return. see http://svn.boost.org/trac/boost/ticket/1791
The problem code is: throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); return Target(); // normally never reached (throw_exception) Is the problem that the compiler can't be confident that throw_exception won't ever return? (For that matter, can we?) So would it be better to *suppress the warning* ? with a push'n'pop around this: #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 Paul --- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com

Hi, On Wed, Apr 9, 2008 at 4:02 PM, Paul A Bristow <pbristow@hetp.u-net.com> wrote:
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Stephan Diederich Sent: 08 April 2008 20:53 To: boost@lists.boost.org Subject: [boost] [1.35][lexical_cast][concept check][range] Build error andwarnings with MSVC8 on Warning Level 4
As we tried to update to 1.35 today, we found some warnings with MSVC on Warning Level 4 in:
lexical_cast: There was a return statement after a call to throw_exception which causes a unreachable code warning. I can see no problem by just removing that return. see http://svn.boost.org/trac/boost/ticket/1791
The problem code is:
throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); return Target(); // normally never reached (throw_exception)
Is the problem that the compiler can't be confident that throw_exception won't ever return? (For that matter, can we?)
Hm, I'm not sure what you mean. Do you think we exchange one warning with another? "Code not reachable" with "Missing return value"?. I think _we_ can be sure throw_exception does not return. throw_exception doc ( http://tinyurl.com/4vup33 ) says that even the user defined one is not allowed to return.
So would it be better to *suppress the warning* ?
I'm fine with that. Thanks for looking into this! cheers, stephan
with a push'n'pop around this:
#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
Paul
--- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Stephan Diederich Sent: 09 April 2008 17:24 To: boost@lists.boost.org Subject: Re: [boost] [1.35][lexical_cast][concept check][range] Build errorandwarnings with MSVC8 on Warning Level 4
As we tried to update to 1.35 today, we found some warnings with MSVC on Warning Level 4 in:
lexical_cast: There was a return statement after a call to throw_exception which causes a unreachable code warning. I can see no problem by just removing that return. see http://svn.boost.org/trac/boost/ticket/1791
The problem code is:
throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); return Target(); // normally never reached (throw_exception)
Is the problem that the compiler can't be confident that throw_exception won't ever return? (For that matter, can we?)
Hm, I'm not sure what you mean. Do you think we exchange one warning with another? "Code not reachable" with "Missing return value"?. I think _we_ can be sure throw_exception does not return. throw_exception doc ( http://tinyurl.com/4vup33 ) says that even the user defined one is not allowed to return.
Well it actually says "Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined." 'Undefined' is not quite the same as 'won't happen'. In the worst case, the result of excuting the return statement might be less worse ;-) So is it still safer to keep the return? One statement is quite cheap ;-)
So would it be better to *suppress the warning* ?
I'm fine with that.
I'm fine with either - but I'm *not fine* with distracting warnings!
Thanks for looking into this!
cheers, stephan
with a push'n'pop around this:
#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
Paul
--- Paul A Bristow Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB +44 1539561830 & SMS, Mobile +44 7714 330204 & SMS pbristow@hetp.u-net.com
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

On Wed, Apr 9, 2008 at 6:36 PM, Paul A Bristow <pbristow@hetp.u-net.com> wrote:
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Stephan Diederich
Sent: 09 April 2008 17:24 To: boost@lists.boost.org
Subject: Re: [boost] [1.35][lexical_cast][concept check][range] Build errorandwarnings with MSVC8 on Warning Level 4
As we tried to update to 1.35 today, we found some warnings with MSVC on Warning Level 4 in:
lexical_cast: There was a return statement after a call to throw_exception which causes a unreachable code warning. I can see no problem by just removing that return. see http://svn.boost.org/trac/boost/ticket/1791
The problem code is:
throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); return Target(); // normally never reached (throw_exception)
Is the problem that the compiler can't be confident that throw_exception won't ever return? (For that matter, can we?)
Hm, I'm not sure what you mean. Do you think we exchange one warning with another? "Code not reachable" with "Missing return value"?. I think _we_ can be sure throw_exception does not return. throw_exception doc ( http://tinyurl.com/4vup33 ) says that even the user defined one is not allowed to return.
Well it actually says
"Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined."
'Undefined' is not quite the same as 'won't happen'.
In the worst case, the result of excuting the return statement might be less worse ;-)
So is it still safer to keep the return? One statement is quite cheap ;-)
I totally agree. Would be nice to see the warning removed. cheers, stephan
with a push'n'pop around this:
#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

Paul A Bristow <pbristow <at> hetp.u-net.com> writes:
-----Original Message----- From: boost-bounces <at> lists.boost.org [mailto:boost-bounces <at> lists.boost.org] On Behalf Of Stephan Diederich Sent: 08 April 2008 20:53 To: boost <at> lists.boost.org Subject: [boost] [1.35][lexical_cast][concept check][range] Build error andwarnings with MSVC8 on Warning Level 4
As we tried to update to 1.35 today, we found some warnings with MSVC on Warning Level 4 in:
lexical_cast: There was a return statement after a call to throw_exception which causes a unreachable code warning. I can see no problem by just removing that return. see http://svn.boost.org/trac/boost/ticket/1791
Speaking of unreachable code, i get some similar warnings from variant (when building in release mode): boost\variant\detail\visitation_impl.hpp(205) : warning C4702: unreachable code boost\variant\detail\visitation_impl.hpp(180) : warning C4702: unreachable code boost\variant\detail\visitation_impl.hpp(252) : warning C4702: unreachable code boost\variant\detail\visitation_impl.hpp(280) : warning C4702: unreachable code There are some 'should never be here at runtime:' comments in the code in question, but it would still be nice to silence the warnings 'officially'. Thanks, Richard Webb

Hi Richard, If you want to make a patch that silences the warning, that would seem reasonable to me. Thanks, Eric On Tue, Apr 22, 2008 at 2:38 AM, Richard Webb <richard.webb@boldonjames.com> wrote:
Paul A Bristow <pbristow <at> hetp.u-net.com> writes:
-----Original Message----- From: boost-bounces <at> lists.boost.org [mailto:boost-bounces <at> lists.boost.org] On Behalf Of Stephan
Diederich
Sent: 08 April 2008 20:53 To: boost <at> lists.boost.org Subject: [boost] [1.35][lexical_cast][concept check][range] Build error andwarnings with MSVC8 on Warning Level 4
As we tried to update to 1.35 today, we found some warnings with MSVC on Warning Level 4 in:
lexical_cast: There was a return statement after a call to throw_exception which causes a unreachable code warning. I can see no problem by just removing that return. see http://svn.boost.org/trac/boost/ticket/1791
Speaking of unreachable code, i get some similar warnings from variant (when building in release mode):
boost\variant\detail\visitation_impl.hpp(205) : warning C4702: unreachable code boost\variant\detail\visitation_impl.hpp(180) : warning C4702: unreachable code boost\variant\detail\visitation_impl.hpp(252) : warning C4702: unreachable code boost\variant\detail\visitation_impl.hpp(280) : warning C4702: unreachable code
There are some 'should never be here at runtime:' comments in the code in question, but it would still be nice to silence the warnings 'officially'.
Thanks, Richard Webb
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Eric Friedman <ebf <at> users.sourceforge.net> writes:
Hi Richard,
If you want to make a patch that silences the warning, that would seem reasonable to me.
Thanks,
Eric
Hi, All i did locally was to turn the warning off with a pragma. I've added a patch that does this to a previous ticket i opened about variant warnings @ http://svn.boost.org/trac/boost/ticket/1507 . Thanks, Richard Webb
participants (4)
-
Eric Friedman
-
Paul A Bristow
-
Richard Webb
-
Stephan Diederich