Skip to content

Commit 7326e90

Browse files
authored
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)}; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 parent 4075dda commit 7326e90

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flang/runtime/stop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static void PrintBacktrace() {
162162
// TODO: Need to parse DWARF information to print function line numbers
163163
constexpr int MAX_CALL_STACK{999};
164164
void *buffer[MAX_CALL_STACK];
165-
int nptrs{backtrace(buffer, MAX_CALL_STACK)};
165+
int nptrs{(int)backtrace(buffer, MAX_CALL_STACK)};
166166

167167
if (char **symbols{backtrace_symbols(buffer, nptrs)}) {
168168
for (int i = 0; i < nptrs; i++) {

0 commit comments

Comments
 (0)