Skip to content

Commit 9bb12be

Browse files
malfetpytorchmergebot
authored andcommitted
Fix sign-compare violations in python_list.h
`idx` is signed type as well as `len()`, so no need to cast one of the two two unsigned. Prerequisite change for enabling `-Werror=sign-compare` across PyTorch repo Pull Request resolved: pytorch#75076 Approved by: https://github.com/albanD
1 parent a48fe46 commit 9bb12be

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

torch/csrc/jit/python/python_list.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class ScriptList final {
197197
idx += len();
198198
}
199199

200-
if (idx < 0 || (size_type)idx > len()) {
200+
if (idx < 0 || idx > len()) {
201201
throw std::out_of_range("list index out of range");
202202
}
203203

@@ -217,7 +217,7 @@ class ScriptList final {
217217
idx += sz;
218218
}
219219

220-
if (idx < 0 || (size_type)idx >= sz) {
220+
if (idx < 0 || idx >= sz) {
221221
throw std::out_of_range("list index out of range");
222222
}
223223

0 commit comments

Comments
 (0)