Re:In C++, is empty() faster than comparing the size with zero?
by saagarjha on Thursday October 28, 2021 @11:39PM
(#29034903)
Actually, many instances of undefined behavior are born out of a desire for portability. Some processors will fault on both of those and the standard wants to be inclusive of those behaviors. Compilers happen to be able to use the definition of undefined behavior to also optimize code, but the concept is born out of practicality.
Re:In C++, is empty() faster than comparing the size with zero?
by secondcoming on Thursday October 28, 2021 @06:52PM
(#29033066)
And so you get an optimal, but broken, program. This helps nobody.
That is literally reason why any behavior is considered undefined. So that the compiler can skip checks to produce better optimized code.