From 37968845284501a536a96b9fdafab83d43dd9b9d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 27 Mar 2025 10:03:58 +0100 Subject: gh-111178: Skip undefined behavior checks in _PyPegen_lookahead() (#131714) For example, expression_rule() return type is 'expr_ty', whereas _PyPegen_lookahead() uses 'void*'. --- Parser/pegen.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Parser/pegen.c b/Parser/pegen.c index 592269e..75fdd46 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -406,11 +406,14 @@ _PyPegen_lookahead_with_int(int positive, Token *(func)(Parser *, int), Parser * return (res != NULL) == positive; } -int +// gh-111178: Use _Py_NO_SANITIZE_UNDEFINED to disable sanitizer checks on +// undefined behavior (UBsan) in this function, rather than changing 'func' +// callback API. +int _Py_NO_SANITIZE_UNDEFINED _PyPegen_lookahead(int positive, void *(func)(Parser *), Parser *p) { int mark = p->mark; - void *res = (void*)func(p); + void *res = func(p); p->mark = mark; return (res != NULL) == positive; } -- cgit v0.12