[flang-commits] [flang] 7326e90 - flang: fix backtrace build on FreeBSD (#120297)
via flang-commits
flang-commits at lists.llvm.org
Thu Jan 2 09:06:32 PST 2025
Author: Brooks Davis
Date: 2025-01-02T12:06:29-05:00
New Revision: 7326e903d72ba390a6368ff3e9eb2ab2251a1b13
URL: https://github.com/llvm/llvm-project/commit/7326e903d72ba390a6368ff3e9eb2ab2251a1b13
DIFF: https://github.com/llvm/llvm-project/commit/7326e903d72ba390a6368ff3e9eb2ab2251a1b13.diff
LOG: flang: fix backtrace build on FreeBSD (#120297)
FreeBSD's libexecinfo defines backtrace with a size_t for the size
argument and return type. This almost certainly doesn't make sense, but
what's done is done so cast the output to allow compilation. Otherwise
we get:
.../flang/runtime/stop.cpp:165:13: error: non-constant-expression cannot
be narrowed from type 'size_t' (aka 'unsigned long') to 'int' in
initializer list [-Wc++11-narrowing]
165 | int nptrs{backtrace(buffer, MAX_CALL_STACK)};
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Added:
Modified:
flang/runtime/stop.cpp
Removed:
################################################################################
diff --git a/flang/runtime/stop.cpp b/flang/runtime/stop.cpp
index f8457e10566a23..a7be8a082e026b 100644
--- a/flang/runtime/stop.cpp
+++ b/flang/runtime/stop.cpp
@@ -162,7 +162,7 @@ static void PrintBacktrace() {
// TODO: Need to parse DWARF information to print function line numbers
constexpr int MAX_CALL_STACK{999};
void *buffer[MAX_CALL_STACK];
- int nptrs{backtrace(buffer, MAX_CALL_STACK)};
+ int nptrs{(int)backtrace(buffer, MAX_CALL_STACK)};
if (char **symbols{backtrace_symbols(buffer, nptrs)}) {
for (int i = 0; i < nptrs; i++) {
More information about the flang-commits
mailing list