From 2b1a2c7a19a3221e0e5abde40970dc408074a58f Mon Sep 17 00:00:00 2001 From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com> Date: Fri, 6 Oct 2023 00:53:40 -0400 Subject: [PATCH] Fix useless cast warning --- src/platform/utils.hpp | 4 ++++ src/unwind/unwind_with_dbghelp.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/platform/utils.hpp b/src/platform/utils.hpp index 8fd3e25..7853960 100644 --- a/src/platform/utils.hpp +++ b/src/platform/utils.hpp @@ -333,6 +333,10 @@ namespace detail { unsigned long long to_ull(T t) { return static_cast(t); } + template + unsigned long long to_uintptr(T t) { + return static_cast(t); + } // A way to cast to U without "warning: useless cast to type" template diff --git a/src/unwind/unwind_with_dbghelp.cpp b/src/unwind/unwind_with_dbghelp.cpp index f1005af..33c5d30 100644 --- a/src/unwind/unwind_with_dbghelp.cpp +++ b/src/unwind/unwind_with_dbghelp.cpp @@ -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 // 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. - trace.push_back(static_cast(frame.AddrPC.Offset) - 1); + trace.push_back(to_uintptr(frame.AddrPC.Offset) - 1); } } else { // base