Skip to content

time_clockid_converter() selects the wrong type for clockid_t on Cygwin. #134771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
collinfunk opened this issue May 27, 2025 · 0 comments
Closed
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@collinfunk
Copy link
Contributor

collinfunk commented May 27, 2025

Bug report

Bug description:

Building Python from the main branch on Python fails with the following error:

gcc  -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall    -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal -I./Include/internal/mimalloc  -I. -I./Include    -DPy_BUILD_CORE_BUILTIN -c ./Modules/timemodule.c -o Modules/timemodule.o
In file included from ./Include/Python.h:19,
                 from ./Modules/timemodule.c:3:
./Modules/timemodule.c: In function ‘time_clockid_converter’:
./Include/pymacro.h:118:13: error: static assertion failed: "sizeof(clk_id) == sizeof(*p)"
  118 |             static_assert((cond), #cond); \
      |             ^~~~~~~~~~~~~
./Modules/timemodule.c:203:5: note: in expansion of macro ‘Py_BUILD_ASSERT’
  203 |     Py_BUILD_ASSERT(sizeof(clk_id) == sizeof(*p));
      |     ^~~~~~~~~~~~~~~
make: *** [Makefile:3789: Modules/timemodule.o] Error 1

This is because we use int clk_id = PyLong_AsInt(obj); when it should be a long on this platform.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Linked PRs

@collinfunk collinfunk added the type-bug An unexpected behavior, bug, or error label May 27, 2025
collinfunk added a commit to collinfunk/cpython that referenced this issue May 27, 2025
Use long for clockid_t instead of int.
collinfunk added a commit to collinfunk/cpython that referenced this issue May 27, 2025
Use long for clockid_t instead of int.
collinfunk added a commit to collinfunk/cpython that referenced this issue May 27, 2025
Use long for clockid_t instead of int.
vstinner pushed a commit that referenced this issue May 29, 2025
Use long for clockid_t instead of int.
@picnixz picnixz added the extension-modules C modules in the Modules dir label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
Projects
Development

No branches or pull requests

3 participants