Skip to content

Fix gcc compiler warnings #5523

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ jobs:
run: |
pip install setuptools
pytest tests/extra_setuptools
if: "!(matrix.runs-on == 'windows-2022')"
if: matrix.runs-on != 'windows-2022'

manylinux:
name: Manylinux on 🐍 3.13t • GIL
Expand Down Expand Up @@ -360,9 +360,10 @@ jobs:
container_suffix: "-bookworm"
- clang: 18
std: 20
cxx_flags: "-Werror -Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls"
container_suffix: "-bookworm"

name: "🐍 3 • Clang ${{ matrix.clang }} • C++${{ matrix.std }} • x64"
name: "🐍 3 • Clang ${{ matrix.clang }} • C++${{ matrix.std }} • x64${{ matrix.cxx_flags && ' • cxx_flags' || '' }}"
container: "silkeh/clang:${{ matrix.clang }}${{ matrix.container_suffix }}"

steps:
Expand All @@ -378,6 +379,7 @@ jobs:
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
-DCMAKE_CXX_STANDARD=${{ matrix.std }}
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")

- name: Build
Expand Down Expand Up @@ -521,11 +523,11 @@ jobs:
- { gcc: 9, std: 20 }
- { gcc: 10, std: 17 }
- { gcc: 10, std: 20 }
- { gcc: 11, std: 20 }
- { gcc: 11, std: 20, cxx_flags: "-Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls" }
- { gcc: 12, std: 20 }
- { gcc: 13, std: 20 }
- { gcc: 13, std: 20, cxx_flags: "-Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls" }

name: "🐍 3 • GCC ${{ matrix.gcc }} • C++${{ matrix.std }}• x64"
name: "🐍 3 • GCC ${{ matrix.gcc }} • C++${{ matrix.std }} • x64${{ matrix.cxx_flags && ' • cxx_flags' || '' }}"
container: "gcc:${{ matrix.gcc }}"

steps:
Expand All @@ -547,6 +549,7 @@ jobs:
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
-DCMAKE_CXX_STANDARD=${{ matrix.std }}
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")

- name: Build
Expand Down
2 changes: 0 additions & 2 deletions include/pybind11/detail/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,6 @@ extern "C" inline void pybind11_object_dealloc(PyObject *self) {
Py_DECREF(type);
}

std::string error_string();

/** Create the type which can be used as a common base for all classes. This is
needed in order to satisfy Python's requirements for multiple inheritance.
Return value: New reference. */
Expand Down
3 changes: 0 additions & 3 deletions include/pybind11/gil.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

PYBIND11_NAMESPACE_BEGIN(detail)

// forward declarations
PyThreadState *get_thread_state_unchecked();

PYBIND11_NAMESPACE_END(detail)

#if !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
Expand Down
1 change: 1 addition & 0 deletions include/pybind11/gil_safe_call_once.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once

#include "detail/common.h"
#include "detail/type_caster_base.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I think this is going in the wrong direction:

It brings in a ton of dependencies unrelated to the gil_safe_call_once functionality.

It's seems counter-productive to turn on compiler warnings just to appease them.

A great step forward would be to refactor the code organization. I'd be very happy if you did that, even if several pieces of code need to be moved around.

If you think that's too much work: Simply disable the warnings for the troublesome existing forward declaration. That'd be a net gain: Having the warnings enabled will nudge us in the right direction when working on new code. The warning suppressions will remind us that we have a code organization cleanup job waiting for an intrepid volunteer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. For restructuring the code, I'm not an expert enough. I will disable the warnings. Switching to draft state for now.

#include "gil.h"

#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ elseif(MSVC)
else()
file(
WRITE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
"#include <filesystem>\nint main(int argc, char ** argv) {\n std::filesystem::path p(argv[0]);\n return p.string().length();\n}"
"#include <filesystem>\nint main(int /*argc*/, char ** argv) {\n std::filesystem::path p(argv[0]);\n return p.string().length();\n}"
)
try_compile(
STD_FS_NO_LIB_NEEDED ${CMAKE_CURRENT_BINARY_DIR}
Expand Down
Loading