Opened 11 years ago
Closed 10 years ago
#6762 closed Patches (fixed)
missing return value in function
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.50.0 | Component: | chrono |
Version: | Boost 1.49.0 | Severity: | Problem |
Keywords: | chrono warning end non-void | Cc: |
Description
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:
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:
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 }
Change History (3)
comment:1 by , 10 years ago
Component: | None → chrono |
---|---|
Owner: | set to |
comment:2 by , 10 years ago
Status: | new → assigned |
---|
comment:3 by , 10 years ago
Milestone: | To Be Determined → Boost 1.50.0 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Fixed in release branch.