-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Unoptimized build will generate dead code for code like return rand(); even if it will never be executed. The dead code can be avoided by enclosing in else scope (see fooB in the godbolt example).
template<int i>
int fooA(){
if constexpr(i<10){
return 0;
}
return rand();
}
There are some patterns like this in the current library. For example, the following lines can be enclosed in else scope.
Line 2053 in 313964b
| return true; |
Line 3915 in 313964b
| ++_It._Get_current(); |
Line 5736 in 313964b
| const auto _Validate = [&] { |
And this is not used by all constexpr return branches:
Line 5117 in 313964b
| tm _Time; |
And these (though consteval; for style consistency) can be made into else branch:
Line 4539 in 313964b
| return {_St::_None}; |
STL/stl/inc/__msvc_ranges_to.hpp
Line 615 in 313964b
| return {_St::_None}; |
And due to this, I guess is_constant_evaluated() is causing a lot of unavoidable dead code in debug build. See fooC in the godbolt example.