Issue 54739
Summary truncation in conversion from uint64_t to size_t
Labels
Assignees
Reporter msebor
    As pointed out in https://reviews.llvm.org/D122836#3423517, passing the `uint64_t` result of `getZExtValue()` to `StringRef::substr(size_t, size_t)` as is done below might silently truncate the value in ILP32.  This is just a reminder to review and fix that and any other calls like it.

```
lib/Transforms/Utils/SimplifyLibCalls.cpp:  Str = Str.substr(0, LenC->getZExtValue());
```

It looks like the code in `DWARFUnit::tryExtractDIEsIfNeeded` in `llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp` might be subject to the sametruncation:
```
    if (auto *IndexEntry = Header.getIndexEntry())
      if (const auto *C = IndexEntry->getContribution(
              Header.getVersion() >= 5 ? DW_SECT_LOCLISTS : DW_SECT_EXT_LOC))
        Data = "" C->Length);
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to