Skip to content

Commit 78ed38c

Browse files
apavlyutkincopybara-github
authored andcommitted
PR #1783: [riscv][debugging] Fix a few warnings in RISC-V inlines
Imported from GitHub PR abseil/abseil-cpp#1783 Today we cannot build V8 (which uses the Abseil library) in strict mode for RISC-V due to a few warnings in debbugging inlines. All the warnings are about implicit signed to unsigned conversion and precision losses, nothing serious, but they are still very annoying. Merge 7b2a865021ca18e3666c544000b6b1258964f6c4 into 8596c6e Merging this change closes #1783 COPYBARA_INTEGRATE_REVIEW=abseil/abseil-cpp#1783 from apavlyutkin:riscv-fix-warnings 7b2a865021ca18e3666c544000b6b1258964f6c4 PiperOrigin-RevId: 693802454 Change-Id: Ibfefc9370606a6b8ec217ac6d87d7c6d70d1a3ce
1 parent e83ef27 commit 78ed38c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

absl/debugging/internal/stacktrace_riscv-inl.inc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
#include "absl/base/attributes.h"
3737
#include "absl/debugging/stacktrace.h"
3838

39-
static const uintptr_t kUnknownFrameSize = 0;
39+
static constexpr ptrdiff_t kUnknownFrameSize = 0;
4040

4141
// Compute the size of a stack frame in [low..high). We assume that low < high.
4242
// Return size of kUnknownFrameSize.
4343
template <typename T>
44-
static inline uintptr_t ComputeStackFrameSize(const T *low, const T *high) {
44+
static inline ptrdiff_t ComputeStackFrameSize(const T *low, const T *high) {
4545
const char *low_char_ptr = reinterpret_cast<const char *>(low);
4646
const char *high_char_ptr = reinterpret_cast<const char *>(high);
4747
return low < high ? high_char_ptr - low_char_ptr : kUnknownFrameSize;
@@ -93,8 +93,8 @@ static void ** NextStackFrame(void **old_frame_pointer, const void *uc,
9393

9494
// Check frame size. In strict mode, we assume frames to be under 100,000
9595
// bytes. In non-strict mode, we relax the limit to 1MB.
96-
const uintptr_t max_size = STRICT_UNWINDING ? 100000 : 1000000;
97-
const uintptr_t frame_size =
96+
const ptrdiff_t max_size = STRICT_UNWINDING ? 100000 : 1000000;
97+
const ptrdiff_t frame_size =
9898
ComputeStackFrameSize(old_frame_pointer, new_frame_pointer);
9999
if (frame_size == kUnknownFrameSize) {
100100
if (STRICT_UNWINDING)
@@ -151,7 +151,9 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count,
151151
} else {
152152
result[n] = return_address;
153153
if (IS_STACK_FRAMES) {
154-
sizes[n] = ComputeStackFrameSize(frame_pointer, next_frame_pointer);
154+
// NextStackFrame() has already checked that frame size fits to int
155+
sizes[n] = static_cast<int>(ComputeStackFrameSize(frame_pointer,
156+
next_frame_pointer));
155157
}
156158
n++;
157159
}

0 commit comments

Comments
 (0)