https://llvm.org/bugs/show_bug.cgi?id=30515
Bug ID: 30515
Summary: out of range iterator usage in
getLongestCommonPrefixLen (r280895)
Product: new-bugs
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
getLongestCommonPrefixLen calls the three-argument version of std::mismatch:
std::mismatch(Strings[0].begin(), Strings[0].end(), Strings[I].begin())
with this call, Strings[I].end() is *assumed* to be Strings[I].begin() +
Strings[0].end() - Strings[0].begin(), see:
http://en.cppreference.com/w/cpp/algorithm/mismatch
If last2 is not provided (overloads (1-4)), it denotes first2 + (last1 -
first1).
in case String[I] is a prefix of Strings[0], std::mismatch will continue
increasing its iterator outside String[I]. This is caught by Visual C++ runtime
lib in debug mode, "string iterator + offset out of range". the code probably
works since the strings are null-terminated but at least VC thinks it is wrong.
the four-argument std::mismatch could solve this but sadly is C++ 17.
maybe it's best just to hardcode the while loop.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs