llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> That doesn't work. Fixes #<!-- -->152903 --- Full diff: https://github.com/llvm/llvm-project/pull/155173.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Interp.cpp (+2-2) - (modified) clang/test/AST/ByteCode/cxx11.cpp (+2) ``````````diff diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 796c24e9071ec..d4525c8288c68 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -2117,8 +2117,8 @@ bool DiagTypeid(InterpState &S, CodePtr OpPC) { bool arePotentiallyOverlappingStringLiterals(const Pointer &LHS, const Pointer &RHS) { - unsigned LHSOffset = LHS.getIndex(); - unsigned RHSOffset = RHS.getIndex(); + unsigned LHSOffset = LHS.isOnePastEnd() ? LHS.getNumElems() : LHS.getIndex(); + unsigned RHSOffset = RHS.isOnePastEnd() ? RHS.getNumElems() : RHS.getIndex(); unsigned LHSLength = (LHS.getNumElems() - 1) * LHS.elemSize(); unsigned RHSLength = (RHS.getNumElems() - 1) * RHS.elemSize(); diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp index 08caca03b8056..72bc7622eb6d8 100644 --- a/clang/test/AST/ByteCode/cxx11.cpp +++ b/clang/test/AST/ByteCode/cxx11.cpp @@ -287,6 +287,8 @@ namespace OverlappingStrings { constexpr bool may_overlap_4 = &"xfoo"[1] == &"xfoo"[1]; // both-error {{}} both-note {{addresses of potentially overlapping literals}} + /// Used to crash. + const bool x = &"ab"[0] == &"ba"[3]; } `````````` </details> https://github.com/llvm/llvm-project/pull/155173 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits