Fix useless cast warning

This commit is contained in:
Jeremy 2023-10-06 00:53:40 -04:00
parent 2f507cc24d
commit 2b1a2c7a19
No known key found for this signature in database
GPG Key ID: 19AA8270105E8EB4
2 changed files with 5 additions and 1 deletions

View File

@ -333,6 +333,10 @@ namespace detail {
unsigned long long to_ull(T t) { unsigned long long to_ull(T t) {
return static_cast<unsigned long long>(t); return static_cast<unsigned long long>(t);
} }
template<typename T>
unsigned long long to_uintptr(T t) {
return static_cast<uintptr_t>(t);
}
// A way to cast to U without "warning: useless cast to type" // A way to cast to U without "warning: useless cast to type"
template<typename U, typename V> template<typename U, typename V>

View File

@ -138,7 +138,7 @@ namespace detail {
// On x86/x64/arm, as far as I can tell, the frame return address is always one after the call // On x86/x64/arm, as far as I can tell, the frame return address is always one after the call
// So we just decrement to get the pc back inside the `call` / `bl` // So we just decrement to get the pc back inside the `call` / `bl`
// This is done with _Unwind too but conditionally based on info from _Unwind_GetIPInfo. // This is done with _Unwind too but conditionally based on info from _Unwind_GetIPInfo.
trace.push_back(static_cast<uintptr_t>(frame.AddrPC.Offset) - 1); trace.push_back(to_uintptr(frame.AddrPC.Offset) - 1);
} }
} else { } else {
// base // base