Skip to content

Compiler warnings in main / 3.11 #96017

Closed
@tiran

Description

@tiran

Bug report

I'm getting several compiler warnings when compiling on Linux X86_64, wasm32-emscripten, and wasm32-wasi.

Your environment

  • x86_64-pc-linux-gnu with gcc
  • wasm32-emscripten with clang
  • wasm32-wasi with clang

warnings

Objects/typeobject.c:6805:34: warning: comparison of integers of different signs: 'Py_ssize_t' (aka 'long') and 'unsigned long' [-Wsign-compare]
    else if (type->tp_dictoffset < sizeof(PyObject)) {

Fix: cast sizeof to Py_ssize_t

Objects/typeobject.c:74:1: warning: unused function 'static_builtin_index_is_set' [-Wunused-function]
static_builtin_index_is_set(PyTypeObject *self)
^

Fix: don't define the function if NDEBUG is set.

Modules/_testcapi/heaptype.c:280:23: warning: unused variable 'class_ht' [-Wunused-variable]
    PyHeapTypeObject *class_ht = (PyHeapTypeObject *)class;
Modules/_testcapi/heaptype.c:279:19: warning: unused variable 'class_tp' [-Wunused-variable]
    PyTypeObject *class_tp = (PyTypeObject *)class;

Fix: unset NDEBUG before including assert.h.

Python/ceval_gil.h:136:13: warning: unused function 'recreate_gil' [-Wunused-function]
static void recreate_gil(struct _gil_runtime_state *gil)

Fix: only define function ifdef HAVE_FORK

Python/pytime.c:297:10: warning: implicit conversion from 'long long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-const-int-float-conversion]
    if (!_Py_InIntegralTypeRange(time_t, intpart)) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Include/internal/pycore_pymath.h:72:45: note: expanded from macro '_Py_InIntegralTypeRange'
    (_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type))
                                         ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
Include/internal/pycore_pymath.h:61:88: note: expanded from macro '_Py_IntegralTypeMax'
    (_Py_IS_TYPE_SIGNED(type) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)

The warning is coming from clang from WASI-SDK.

Modules/expat/xmlparse.c:3107:9: warning: code will never be executed [-Wunreachable-code]
        parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf,
        ^~~~~~
Modules/expat/xmlparse.c:3106:16: note: silence by adding parentheses to mark code as explicitly dead
      else if (0 && parser->m_characterDataHandler)
               ^
               /* DISABLES CODE */ ( )
Modules/expat/xmlparse.c:4050:9: warning: code will never be executed [-Wunreachable-code]
        parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf,
        ^~~~~~
Modules/expat/xmlparse.c:4049:16: note: silence by adding parentheses to mark code as explicitly dead
      else if (0 && parser->m_characterDataHandler)
               ^
               /* DISABLES CODE */ ( )
Modules/expat/xmlparse.c:7681:11: warning: format specifies type 'int' but the argument has type 'ptrdiff_t' (aka 'long') [-Wformat]
          bytesMore, (account == XML_ACCOUNT_DIRECT) ? "DIR" : "EXP",
          ^~~~~~~~~
3 warnings generated.

The warnings are coming from clang from WASI-SDK. These look like issues in upstream expat code.

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixesOS-wasitype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions