gh-121647: Prefer decltype() for _Py_TYPEOF() on C++ - #157267
Conversation
Using MSVC (on Windows), prefer decltype() over __typeof__() on C++.
|
!buildbot AMD64 Windows11 Non-Debug 3.x PR |
|
The regex 'AMD64 Windows11 Non-Debug 3.x PR' did not match any buildbot builder. Is the requested builder in the list of stable builders? |
|
Right now, I don't access to a Windows machine to test my change, so I will rely on Windows buildbots for now. |
|
!buildbot AMD64 Windows11 Non-Debug 3.x |
|
The regex 'AMD64 Windows11 Non-Debug 3.x' did not match any buildbot builder. Is the requested builder in the list of stable builders? |
|
!buildbot AMD64 Windows11 Non-Debug |
|
🤖 New build scheduled with the buildbot fleet by @chris-eibl for commit 85a6ba9 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157267%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
|
Oh, test_cppext failed on "Ubuntu / build and test (ubuntu-26.04-arm)" CI: test.pythoninfo says |
|
Sadly, it still fails with the same error. I suppose that MSVC doesn't target C++11 by default. Even
By the way, test_limited_cpp03ext logs a compiler warning:
|
Without /Zc:__cplusplus MSVC always sets
Maybe we can use the _MSVC_LANG preprocessor macro, because many people do not use
Yupp, that's not a valid option per https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-170. It "starts" with
But again, without |
|
!buildbot AMD64 Windows11 Non-Debug PR |
|
🤖 New build scheduled with the buildbot fleet by @vstinner for commit 13de0a0 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157267%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
Ok, let me retry with _MSVC_LANG macro :-) |
Replace "_Py_TYPEOF(dst)*" with "_Py_TYPEOF(&(dst))". In C++, "_Py_TYPEOF(dst)*" can fail with a compiler error.
|
For the Ubuntu failure, I can reproduce it locally on Fedora 44 (GCC 16.2.1) with the C program: It fails to build with: The fix is to replace |
|
Since _MSVC_LANG is always set when locally. Given that MSVC doesn't support anything older than @unittest.skipIf(support.MS_WINDOWS, "MSVC doesn't support /std:c++11")
def test_build_cpp11(self): |
|
!buildbot AMD64 Windows11 Non-Debug PR |
|
🤖 New build scheduled with the buildbot fleet by @chris-eibl for commit ae56459 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157267%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
I pushed a change for that. |
|
Ah good, test_cppext passed on "Ubuntu / build and test (ubuntu-26.04-arm)" CI. |
|
Aha, test_cppext also passed on the Windows buildbot. |
|
!buildbot Windows |
|
🤖 New build scheduled with the buildbot fleet by @vstinner for commit dec5373 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157267%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
Using MSVC (on Windows), prefer decltype() over typeof() on C++.
_Py_TYPEOFon MSVC and other compilers supporting__typeof__#121647