Skip to content

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

Closed
@collinfunk

Description

@collinfunk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions