René's URL Explorer Experiment


Title: [C API] Py_ARRAY_LENGTH() macro is incompatible with g++ -std=gnu++11 · Issue #158810 · python/cpython · GitHub

Open Graph Title: [C API] Py_ARRAY_LENGTH() macro is incompatible with g++ -std=gnu++11 · Issue #158810 · python/cpython

X Title: [C API] Py_ARRAY_LENGTH() macro is incompatible with g++ -std=gnu++11 · Issue #158810 · python/cpython

Description: Bug report Example: #include int main() { int array[] = {1, 2, 3}; return Py_ARRAY_LENGTH(array); } Building this example with g++ -std=gnu++11 example.cpp or just g++ example.cpp fails with: In file included from Include/Pyth...

Open Graph Description: Bug report Example: #include int main() { int array[] = {1, 2, 3}; return Py_ARRAY_LENGTH(array); } Building this example with g++ -std=gnu++11 example.cpp or just g++ example.cpp fails ...

X Description: Bug report Example: #include <Python.h> int main() { int array[] = {1, 2, 3}; return Py_ARRAY_LENGTH(array); } Building this example with g++ -std=gnu++11 example.cpp or just g++ example.cpp ...

Opengraph URL: https://github.com/python/cpython/issues/158810

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[C API] Py_ARRAY_LENGTH() macro is incompatible with g++ -std=gnu++11","articleBody":"### Bug report\n\nExample:\n\n```c++\n#include \u003cPython.h>\n\nint main()\n{\n    int array[] = {1, 2, 3};\n    return Py_ARRAY_LENGTH(array);\n}\n```\n\nBuilding this example with `g++ -std=gnu++11 example.cpp` or just `g++ example.cpp` fails with:\n\n```\nIn file included from Include/Python.h:70,\n                 from x.cpp:1:\nx.cpp: In function ‘int main()’:\nInclude/pymacro.h:217:30: error: ‘__builtin_types_compatible_p’ was not declared in this scope\n  217 |      + Py_BUILD_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(array), \\\n      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n```\n\nThe example builds correctly if I use `-std=c++11` (`g++ -std=c++11 example.cpp`).\n\nThe macro is currently defined as:\n\n```c++\n#define Py_ARRAY_LENGTH(array) \\\n    (sizeof(array) / sizeof((array)[0]) \\\n     + Py_BUILD_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(array), \\\n                                                          typeof(&(array)[0]))))\n#else\n#define Py_ARRAY_LENGTH(array) \\\n    (sizeof(array) / sizeof((array)[0]))\n#endif\n```\n\nI'm not sure why `__builtin_types_compatible_p()` is available with `-std=c++11`, but not with `-std=gnu++11`.\n\nI made my tests using g++ (GCC) 16.2.1 on Fedora 44.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-158812\n* gh-158838\n* gh-159315\n* gh-159317\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/vstinner","@type":"Person","name":"vstinner"},"datePublished":"2026-10-04T22:24:08Z","url":"https://github.com/python/cpython/issues/158810"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:dbd34675-de1e-2342-490f-e894b221e49a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8900:21AC3F:42C9BE2:547E37B:6B0207C4
html-safe-nonce3cfc03cb247d0067dfa624a017ab845b5372bbaad2316266dd5491eb7074578d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTAwOjIxQUMzRjo0MkM5QkUyOjU0N0UzN0I6NkIwMjA3QzQiLCJ2aXNpdG9yX2lkIjoiNjU2MDk1MTcyMjAxMTkyMDMyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac507e819ef74c57044ddfd949e63c34eab8abfdb48880291b06b3fbfd886de64d
hovercard-subject-tagissue:5703873401
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/158810/issue_layout
twitter:imagehttps://opengraph.githubassets.com/91aa300192c7193d33eedf574d1272ff515c567b8022105793433e9920135d2e/python/cpython/issues/158810
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/91aa300192c7193d33eedf574d1272ff515c567b8022105793433e9920135d2e/python/cpython/issues/158810
og:image:altBug report Example: #include int main() { int array[] = {1, 2, 3}; return Py_ARRAY_LENGTH(array); } Building this example with g++ -std=gnu++11 example.cpp or just g++ example.cpp fails ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamevstinner
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/158810#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F158810
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F158810
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/158810
Reloadhttps://github.com/python/cpython/issues/158810
Reloadhttps://github.com/python/cpython/issues/158810
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/158810
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/158810
[C API] Py_ARRAY_LENGTH() macro is incompatible with g++ -std=gnu++11https://github.com/python/cpython/issues/158810#top
buildThe build process and cross-buildhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22build%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-C-APIhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-C-API%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Oct 4, 2026https://github.com/python/cpython/issues/158810#issue-5703873401
gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ #158812https://github.com/python/cpython/pull/158812
gh-158810: Use _Py_TYPEOF in Py_ARRAY_LENGTH() #158838https://github.com/python/cpython/pull/158838
[3.15] gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ #159315https://github.com/python/cpython/pull/159315
[3.14] gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ #159317https://github.com/python/cpython/pull/159317
vstinnerhttps://github.com/vstinner
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
topic-C-APIhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-C-API%22
on Oct 4, 2026https://github.com/python/cpython/issues/158810#event-32464210540
vstinnerhttps://github.com/vstinner
on Oct 4, 2026https://github.com/python/cpython/issues/158810#event-32464244489
https://github.com/da-woods
da-woodshttps://github.com/da-woods
on Oct 4, 2026https://github.com/python/cpython/issues/158810#issuecomment-5985294059
vstinnerhttps://github.com/vstinner
on Oct 4, 2026https://github.com/python/cpython/issues/158810#event-32465818666
pythongh-158810: Fix Py_ARRAY_LENGTH() macro on C++https://github.com/vstinner/cpython/commit/9d6063a43c8f683c35e44693109ea990bfe4af91
pythongh-158810https://github.com/python/cpython/issues/158810
9d6063ahttps://github.com/vstinner/cpython/commit/9d6063a43c8f683c35e44693109ea990bfe4af91
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Oct 4, 2026https://github.com/python/cpython/issues/158810#issuecomment-5985510734
@da-woodshttps://github.com/da-woods
gh-158812https://github.com/python/cpython/pull/158812
https://github.com/chris-eibl
chris-eiblhttps://github.com/chris-eibl
on Oct 5, 2026https://github.com/python/cpython/issues/158810#issuecomment-5989196822
std::sizehttps://en.cppreference.com/cpp/iterator/size
#157649 (comment)https://github.com/python/cpython/issues/157649#issuecomment-5812458036
picnixzhttps://github.com/picnixz
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
buildThe build process and cross-buildhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22build%22
on Oct 5, 2026https://github.com/python/cpython/issues/158810#event-32493942333
vstinnerhttps://github.com/vstinner
on Oct 5, 2026https://github.com/python/cpython/issues/158810#event-32503073472
gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ (#158812)https://github.com/python/cpython/commit/b2bfbce9a2cb00cb75c08230698cde408c130c92
gh-158810https://github.com/python/cpython/issues/158810
#158812https://github.com/python/cpython/pull/158812
b2bfbcehttps://github.com/python/cpython/commit/b2bfbce9a2cb00cb75c08230698cde408c130c92
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Oct 5, 2026https://github.com/python/cpython/issues/158810#issuecomment-5993735177
std::sizehttps://en.cppreference.com/cpp/iterator/size
#157649 (comment)https://github.com/python/cpython/issues/157649#issuecomment-5812458036
@da-woodshttps://github.com/da-woods
@chris-eiblhttps://github.com/chris-eibl
vstinnerhttps://github.com/vstinner
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 5, 2026https://github.com/python/cpython/issues/158810#event-32503972262
vstinnerhttps://github.com/vstinner
on Oct 6, 2026https://github.com/python/cpython/issues/158810#event-32555380654
gh-158810: Use _Py_TYPEOF in Py_ARRAY_LENGTH() (#158838)https://github.com/python/cpython/commit/85c03d47a240247d41799c2075f85f690558534c
gh-158810https://github.com/python/cpython/issues/158810
#158838https://github.com/python/cpython/pull/158838
85c03d4https://github.com/python/cpython/commit/85c03d47a240247d41799c2075f85f690558534c
vstinnerhttps://github.com/vstinner
on Oct 13, 2026https://github.com/python/cpython/issues/158810#event-33137358194
[3.15] gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ (#159315)https://github.com/python/cpython/commit/152185fdf81515df55925e0bebccb9000c34cb11
gh-158810https://github.com/python/cpython/issues/158810
#159315https://github.com/python/cpython/pull/159315
152185fhttps://github.com/python/cpython/commit/152185fdf81515df55925e0bebccb9000c34cb11
[3.14] gh-158810: Fix Py_ARRAY_LENGTH() macro on C++ (#159317)https://github.com/python/cpython/commit/931322bccfe073030f49311c10f391ebb539ec18
gh-158810https://github.com/python/cpython/issues/158810
#159317https://github.com/python/cpython/pull/159317
931322bhttps://github.com/python/cpython/commit/931322bccfe073030f49311c10f391ebb539ec18
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/158810
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/158810
buildThe build process and cross-buildhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22build%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-C-APIhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-C-API%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.