Skip to content

Commit cc551ad

Browse files
authored
Appease MSVC Warning C4866: compiler may not enforce left-to-right evaluation order (#5955)
1 parent d36f5dd commit cc551ad

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

include/pybind11/pybind11.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,10 +1081,11 @@ 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-
// 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;
1084+
// Cast values into handles before indexing into kwargs to ensure
1085+
// well-defined evaluation order (MSVC C4866).
1086+
handle arg_in_arr = args_in_arr[n_args_in + i],
1087+
kwname = PyTuple_GET_ITEM(kwnames_in, i);
1088+
kwargs[kwname] = arg_in_arr;
10881089
}
10891090
}
10901091
call.args.push_back(kwargs);

0 commit comments

Comments
 (0)