-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!
Description
Describe the bug
I found this annoying warning when I was idly testing my library and I'd like it to be dealt with reasonably well if possible
Command-line test case
#include <type_traits>
#include <cmath>
template<typename T> requires ::std::is_arithmetic_v<T>
constexpr T copy_as_negative(auto x,bool negative=1)noexcept{
if constexpr(::std::is_signed_v<decltype(x)>){
if constexpr(::std::is_floating_point_v<decltype(x)>)
return(T)::std::copysign(x,negative?-1:1);
else
return(T)negative?T{}-x:x;
}
else
return x;
}
constexpr auto copy_as_negative(auto x,bool negative=1)noexcept{
return copy_as_negative<decltype(x)>(x,negative);
}
int main() {
copy_as_negative(long double{0}, 1);
}
Compile this program together with /W4
and you will reasonably get a C4244 warning
Expected behavior
no C4244 warning plz
STL version
Microsoft Visual Studio Community 2022 (64 位) - Preview
17.5.0 Preview 1.0
Additional context
The original code is at https://godbolt.org/z/3eav315a1 if anyone needs it
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!