Skip to content

Commit

Permalink
Avoid a -Warray-bounds false positive in GCC 13. (#1639)
Browse files Browse the repository at this point in the history
The exact circumstances when this false positive is triggered are quite
tricky to reproduce, but it happened reproducibly with g++ 13.1 and 13.2 in
a close-source SW I'm working on.  The fix even improves performance by a
very tiny bit: There is no need to copy the std::smatch, having a const
reference is enough.

Just as a side note: -Warray-bounds seems to cause trouble in other
projects, too, so e.g. the Linux kernel has disabled since June 2022.
  • Loading branch information
svenpanne authored Aug 14, 2023
1 parent 67f6ff7 commit afe627e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -4986,7 +4986,7 @@ inline bool parse_www_authenticate(const Response &res,
s = s.substr(pos + 1);
auto beg = std::sregex_iterator(s.begin(), s.end(), re);
for (auto i = beg; i != std::sregex_iterator(); ++i) {
auto m = *i;
const auto &m = *i;
auto key = s.substr(static_cast<size_t>(m.position(1)),
static_cast<size_t>(m.length(1)));
auto val = m.length(2) > 0
Expand Down

0 comments on commit afe627e

Please sign in to comment.