<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - StringRef::count(StringRef) doesn't behave as documented"
href="https://bugs.llvm.org/show_bug.cgi?id=44072">44072</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>StringRef::count(StringRef) doesn't behave as documented
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>benno@bensge.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The StringRef::count(StringRef) documentation reads as follows:
Return the number of non-overlapped occurrences of \arg Str in the string.
However, the implementation of this method actually counts overlapping
occurrences as well.
Minimum example:
`StringRef("abbabba").count("abba")` returns 2, when it should return 1.
There are very few usages of this API in LLVM. I could only find one usage of
this API where the bug actually makes a difference. All other usages used a
search string with length one, the bug doesn't affect this special case.
There are no tests to ensure the correct overlapping-occurrence behavior of
this function.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>