From d3ab710bb4cda09a2eb0efe8228f5c4fe1458b17 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 16 Jul 2021 13:02:50 -0700 Subject: [PATCH] Issue #466 - Prevent compiler warnings regarding Cyc_st_add and string comparisons Were seeing newer versions of clang spamming warnings due to how we were comparing strings here. --- CHANGELOG.md | 1 + include/cyclone/runtime.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbb77517..1830db8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Bug Fixes - Properly handle literal vectors at the top level of compiled code. - Properly escape C strings in compiled code to avoid trigraphs. - Eliminate clang compiler warnings referencing `EOF` when building the runtime. +- Prevent warnings from the C compiler regarding string comparison for emitted code using `Cyc_st_add`. ## 0.30.0 - July 2, 2021 diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index f50212a5..a71be75b 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -723,8 +723,10 @@ object copy2heap(void *data, object obj); #define Cyc_st_add(data, frame) \ { \ gc_thread_data *thd = (gc_thread_data *) data; \ + intptr_t p1 = (intptr_t)frame; \ + intptr_t p2 = (intptr_t)thd->stack_prev_frame; \ /* Do not allow recursion to remove older frames */ \ - if ((void *)frame != (void *)thd->stack_prev_frame) { \ + if (p1 != p2) { \ thd->stack_prev_frame = frame; \ thd->stack_traces[thd->stack_trace_idx] = frame; \ thd->stack_trace_idx = (thd->stack_trace_idx + 1) % MAX_STACK_TRACES; \