Subject: [Boost-bugs] [Boost C++ Libraries] #6762: missing return value in function
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-04-03 15:54:40
#6762: missing return value in function
------------------------------------+---------------------------------------
Reporter: edwinchenloo@⦠| Type: Patches
Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.49.0
Severity: Problem | Keywords: chrono warning end non-void
------------------------------------+---------------------------------------
In the Chrono library gcc caught this:
./boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp:218: warning:
control reaches end of non-void function
Which is a valid compiler error:
{{{
#!python
197 process_system_cpu_clock::time_point process_system_cpu_clock::now()
BOOST_NOEXCEPT
198 {
199 tms tm;
200 clock_t c = ::times( &tm );
201 if ( c == clock_t(-1) ) // error
202 {
203 BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
204 return time_point();
205 }
206 else
207 {
208 if ( chrono_detail::tick_factor() != -1 )
209 {
210 return time_point(
211 microseconds((tm.tms_stime +
tm.tms_cstime)*chrono_detail::tick_factor()));
212 }
213 else
214 {
215 BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
216 }
217 }
218 }
}}}
Apparently the last else condition ought to not occur at runtime. If so,
something like this would be better:
{{{
#!python
197 process_system_cpu_clock::time_point process_system_cpu_clock::now()
BOOST_NOEXCEPT
198 {
199 tms tm;
200 clock_t c = ::times( &tm );
201 if ( c == clock_t(-1) ) // error
202 {
203 BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
204 return time_point();
205 }
206 else
207 {
208 BOOST_ASSERT( chrono_detail::tick_factor() != -1 );
209 }
210 return time_point(
211 microseconds((tm.tms_stime +
tm.tms_cstime)*chrono_detail::tick_factor()));
212 }
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6762> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC