Skip to content

Commit 7effdc5

Browse files
committed
Try to avoid C compiler optimizing out local address
1 parent e4a7a3d commit 7effdc5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Include/internal/pycore_ceval.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,18 @@ extern void _PyEval_DeactivateOpCache(void);
193193

194194
/* --- _Py_EnterRecursiveCall() ----------------------------------------- */
195195

196+
static return_pointer_as_int(char* p) {
197+
return (uintptr_t)p;
198+
}
199+
196200
static inline uintptr_t
197201
_Py_get_machine_stack_pointer(void) {
198202
#if _Py__has_builtin(__builtin_frame_address)
199203
return (uintptr_t)__builtin_frame_address(0);
200204
#else
201205
char here;
202-
return (uintptr_t)&here;
206+
/* Avoid compiler warning about returning stack address */
207+
return return_pointer_as_int(&here);
203208
#endif
204209
}
205210

Python/ceval.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,8 @@ _Py_InitializeRecursionLimits(PyThreadState *tstate)
374374
_tstate->c_stack_top = base + stack_size;
375375
_tstate->c_stack_soft_limit = base + PYOS_STACK_MARGIN_BYTES * 2;
376376
_tstate->c_stack_hard_limit = base + PYOS_STACK_MARGIN_BYTES;
377-
#ifndef _AIX
378377
assert(_tstate->c_stack_soft_limit < here_addr);
379378
assert(here_addr < _tstate->c_stack_top);
380-
#endif
381379
return;
382380
}
383381
# endif

0 commit comments

Comments
 (0)