Skip to content

Commit d36f5dd

Browse files
XuehaiPanrwgk
andauthored
Appease MSVC Warning C4866: compiler may not enforce left-to-right evaluation order (#5953)
* Appease MSVC Warning C4866: compiler may not enforce left-to-right evaluation order * Remove const qualifier * Reword comment to be self-explanatory without PR context The previous comment referenced the MSVC warning but didn't explain why the code is structured as two statements. The revised comment clarifies the intent: fetching the value first ensures well-defined evaluation order. * chore(deps): switch typos to mirror repo Switch from crate-ci/typos to adhtruong/mirrors-typos because pre-commit autoupdate confuses tags in the upstream repo, selecting the mutable `v1` tag instead of pinned versions like `v1.41.0`. See crate-ci/typos#390 --------- Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
1 parent 745e568 commit d36f5dd

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ repos:
119119
args: ["-x.codespell-ignore-lines", "-Lccompiler,intstruct"]
120120

121121
# Also check spelling
122-
- repo: https://github.com/crate-ci/typos
123-
rev: v1
122+
# Use mirror because pre-commit autoupdate confuses tags in the upstream repo.
123+
# See https://github.com/crate-ci/typos/issues/390
124+
- repo: https://github.com/adhtruong/mirrors-typos
125+
rev: "v1.41.0"
124126
hooks:
125127
- id: typos
126128
args: []

include/pybind11/pybind11.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,10 @@ class cpp_function : public function {
10811081
dict kwargs;
10821082
for (size_t i = 0; i < used_kwargs.size(); ++i) {
10831083
if (!used_kwargs[i]) {
1084-
kwargs[PyTuple_GET_ITEM(kwnames_in, i)] = args_in_arr[n_args_in + i];
1084+
// Fetch value before indexing into kwargs to ensure well-defined
1085+
// evaluation order (MSVC C4866).
1086+
PyObject *const arg_in_arr = args_in_arr[n_args_in + i];
1087+
kwargs[PyTuple_GET_ITEM(kwnames_in, i)] = arg_in_arr;
10851088
}
10861089
}
10871090
call.args.push_back(kwargs);

0 commit comments

Comments
 (0)