https://github.com/python/cpython/commit/f0eb7d4c9a2e49aafb858b0c625c2741701bbf42
commit: f0eb7d4c9a2e49aafb858b0c625c2741701bbf42
branch: 3.14
author: Chris Eibl <[email protected]>
committer: Fidget-Spinner <[email protected]>
date: 2025-11-04T20:43:18Z
summary:

[3.14] gh-140513: Fail to compile if _Py_TAIL_CALL_INTERP is set but 
preserve_none and musttail do not exist (GH-140548) (#140923)

gh-140513: Fail to compile if `_Py_TAIL_CALL_INTERP` is set but `preserve_none` 
and `musttail` do not exist. (GH-140548)


(cherry picked from commit 2f60b8f02fe7cb83dd589d9664460082c13e85ef)

Co-authored-by: Krishna Chaitanya 
<[email protected]>

files:
A Misc/NEWS.d/next/Build/2025-10-25-08-07-06.gh-issue-140513.6OhLTs.rst
M 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
index 00000000000000..1035ebf8d781cf
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2025-10-25-08-07-06.gh-issue-140513.6OhLTs.rst
@@ -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.
diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h
index 187ec8fdd26584..37c4b00f86df25 100644
--- a/Python/ceval_macros.h
+++ b/Python/ceval_macros.h
@@ -79,6 +79,14 @@
 #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)
+#       error "Tail calling not supported for MSVC."
+#   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))

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to