[PATCH] D93777: ADT: Fix pointer comparison UB in SmallVector

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 23 15:02:15 PST 2020


dblaikie accepted this revision.
dblaikie added inline comments.
This revision is now accepted and ready to land.


================
Comment at: llvm/include/llvm/ADT/SmallVector.h:142
+    // Use std::less to avoid UB.
+    std::less<const void *> LessThan;
+    return !LessThan(V, First) && LessThan(V, Last);
----------------



================
Comment at: llvm/include/llvm/ADT/SmallVector.h:155
+    // Use std::less to avoid UB.
+    std::less<const void *> LessThan;
+    return !LessThan(First, this->begin()) && !LessThan(Last, First) &&
----------------
Should be able to use std::less<>, I think? Though given the need for 3 calls, probably still nice to alias it like you have.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93777/new/

https://reviews.llvm.org/D93777



More information about the llvm-commits mailing list