Skip to content

Commit 1355023

Browse files
GLinnik21claude
authored andcommitted
Fix Xcode 26 beta 1 warning about VLA folding in KSCxaThrowSwapper (kstenerud#641)
Replace const int with preprocessor macro REQUIRED_FRAMES to ensure the array size is a compile-time constant, eliminating the GNU extension warning about variable length array folding. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent 6b034e5 commit 1355023

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sources/KSCrashRecordingCore/KSCxaThrowSwapper.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,18 @@ static uintptr_t findAddress(void *address)
108108

109109
static void __cxa_throw_decorator(void *thrown_exception, void *tinfo, void (*dest)(void *))
110110
{
111-
const int k_requiredFrames = 2;
111+
#define REQUIRED_FRAMES 2
112112

113113
KSLOG_TRACE("Decorating __cxa_throw");
114114

115115
g_cxa_throw_handler(thrown_exception, tinfo, dest);
116116

117-
void *backtraceArr[k_requiredFrames];
118-
int count = backtrace(backtraceArr, k_requiredFrames);
117+
void *backtraceArr[REQUIRED_FRAMES];
118+
int count = backtrace(backtraceArr, REQUIRED_FRAMES);
119119

120120
Dl_info info;
121-
if (count >= k_requiredFrames) {
122-
if (dladdr(backtraceArr[k_requiredFrames - 1], &info) != 0) {
121+
if (count >= REQUIRED_FRAMES) {
122+
if (dladdr(backtraceArr[REQUIRED_FRAMES - 1], &info) != 0) {
123123
uintptr_t function = findAddress(info.dli_fbase);
124124
if (function != (uintptr_t)NULL) {
125125
KSLOG_TRACE("Calling original __cxa_throw function at %p", (void *)function);
@@ -128,6 +128,7 @@ static void __cxa_throw_decorator(void *thrown_exception, void *tinfo, void (*de
128128
}
129129
}
130130
}
131+
#undef REQUIRED_FRAMES
131132
}
132133

133134
static void perform_rebinding_with_section(const section_t *dataSection, intptr_t slide, nlist_t *symtab, char *strtab,

0 commit comments

Comments
 (0)