Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ repos:
args: ["-x.codespell-ignore-lines", "-Lccompiler,intstruct"]

# Also check spelling
- repo: https://github.com/crate-ci/typos
rev: v1
# Use mirror because pre-commit autoupdate confuses tags in the upstream repo.
# See https://github.com/crate-ci/typos/issues/390
- repo: https://github.com/adhtruong/mirrors-typos
rev: "v1.41.0"
hooks:
- id: typos
args: []
Expand Down
5 changes: 4 additions & 1 deletion include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,10 @@ class cpp_function : public function {
dict kwargs;
for (size_t i = 0; i < used_kwargs.size(); ++i) {
if (!used_kwargs[i]) {
kwargs[PyTuple_GET_ITEM(kwnames_in, i)] = args_in_arr[n_args_in + i];
// Fetch value before indexing into kwargs to ensure well-defined
// evaluation order (MSVC C4866).
PyObject *const arg_in_arr = args_in_arr[n_args_in + i];
kwargs[PyTuple_GET_ITEM(kwnames_in, i)] = arg_in_arr;
Comment on lines +1084 to +1087
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The warning still exists. The problem may be that the order of key casting and assignment is not well-defined.

  C:\Users\runneradmin\AppData\Local\Temp\pip-build-env-tsdbyp__\overlay\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1087,1): error C2220: the following warning is treated as an error [C:\Users\runneradmin\AppData\Local\Temp\tmph2yqzrcl.build-temp\Release\src\_C.vcxproj]
  C:\Users\runneradmin\AppData\Local\Temp\pip-build-env-tsdbyp__\overlay\Lib\site-packages\pybind11\include\pybind11\pybind11.h(1087,1): warning C4866: compiler may not enforce left-to-right evaluation order for call to 'pybind11::detail::object_api<pybind11::handle>::operator[]' [C:\Users\runneradmin\AppData\Local\Temp\tmph2yqzrcl.build-temp\Release\src\_C.vcxproj]

}
}
call.args.push_back(kwargs);
Expand Down
Loading