]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-140513: Fail to compile if `_Py_TAIL_CALL_INTERP` is set but `preserve_none` and...
authorKrishna Chaitanya <141550576+XChaitanyaX@users.noreply.github.com>
Sat, 1 Nov 2025 16:41:23 +0000 (22:11 +0530)
committerGitHub <noreply@github.com>
Sat, 1 Nov 2025 16:41:23 +0000 (16:41 +0000)
Co-authored-by: Chris Eibl <138194463+chris-eibl@users.noreply.github.com>
Misc/NEWS.d/next/Build/2025-10-25-08-07-06.gh-issue-140513.6OhLTs.rst [new file with mode: 0644]
Python/ceval_macros.h

diff --git a/Misc/NEWS.d/next/Build/2025-10-25-08-07-06.gh-issue-140513.6OhLTs.rst b/Misc/NEWS.d/next/Build/2025-10-25-08-07-06.gh-issue-140513.6OhLTs.rst
new file mode 100644 (file)
index 0000000..1035ebf
--- /dev/null
@@ -0,0 +1,2 @@
+Generate a clear compilation error when ``_Py_TAIL_CALL_INTERP`` is enabled but
+either ``preserve_none`` or ``musttail`` is not supported.
index 8083913b1a1cfc577e25acbb4ac74d18a3e00c81..868ab6f755874f3c2e983e4a045186c7c2783bb9 100644 (file)
 #endif
 
 #if _Py_TAIL_CALL_INTERP
+#   if defined(__clang__) || defined(__GNUC__)
+#       if !_Py__has_attribute(preserve_none) || !_Py__has_attribute(musttail)
+#           error "This compiler does not have support for efficient tail calling."
+#       endif
+#   elif defined(_MSC_VER) && (_MSC_VER < 1950)
+#       error "You need at least VS 2026 / PlatformToolset v145 for tail calling."
+#   endif
+
     // Note: [[clang::musttail]] works for GCC 15, but not __attribute__((musttail)) at the moment.
 #   define Py_MUSTTAIL [[clang::musttail]]
 #   define Py_PRESERVE_NONE_CC __attribute__((preserve_none))