Skip to content

Compiler warnings in main / 3.11 #96017

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.

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Aug 16, 2022
  2. added a commit that references this issue on Aug 16, 2022
  3. added
    3.11only security fixes
    3.12only security fixes
    on Aug 16, 2022
  4. tiran commented on Aug 16, 2022

    @tiran
    MemberAuthor

    Petr takes care of parts.h in #95992

  5. added 3 commits that reference this issue on Aug 19, 2022
  6. brettcannon commented on Oct 3, 2022

    @brettcannon
    Member

    I'm going to break out the _Py_InIntegralTypeRange warning as it isn't special to WASM.

  7. vstinner commented on Oct 4, 2022

    @vstinner
    Member

    See issue #97786 for the _Py_InIntegralTypeRange() warning.

  8. added a commit that references this issue on Oct 5, 2022
  9. OTheDev commented on Feb 21, 2023

    @OTheDev
    Contributor

    FYI, the last warning still appears on main but has been addressed upstream :).

  10. vstinner commented on Apr 5, 2023

    @vstinner
    Member

    It's hard to keep track of an issue reported multiple unrelated compiler warnings. Most of them seem to be fixed, so I close the issue. You may open new issues if some warnings are still emitted on latest versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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