| Issue |
174217
|
| Summary |
[Bug] SmallVector:getNewCapacity has unused TSize parameter — remove or use for overflow-safety?
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
yewentao256
|
As described here https://github.com/pytorch/pytorch/issues/171392
In [`c10/util/SmallVector.cpp`](https://github.com/pytorch/pytorch/blob/913ea815a4555747729eb2206266411782f29370/c10/util/SmallVector.cpp#L87C53-L87C58) we have:
`template <class Size_T> static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity)`
Currently `TSize` is unused.
We can:
1. Remove TSize from getNewCapacity (simplify signature), or
2. Use TSize to clamp the maximum capacity (e.g. MaxSize = min(numeric_limits<Size_T>::max(), SIZE_MAX / TSize)) and make growth arithmetic overflow-safe.
What is preferred? I can send a PR with the better option later.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs