[llvm-bugs] [Bug 46564] New: empty range-for loop over map is not optimized away
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jul 2 13:49:53 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46564
Bug ID: 46564
Summary: empty range-for loop over map is not optimized away
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: trass3r at gmail.com
CC: llvm-bugs at lists.llvm.org
#include <algorithm>
#include <map>
#include <string>
#include <vector>
using Map = std::map<int, std::vector<std::string>>;
void f1(const Map& m)
{
for (const auto& p : m)
{ (void)p; }
}
void f2(const Map& m)
{
std::for_each(m.begin(), m.end(), [](const std::pair<const int,
std::vector<std::string>>& p){
(void)p; });
}
Does work for f2. gcc eliminates both:
https://godbolt.org/z/E-LCJV
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200702/36991ebe/attachment.html>
More information about the llvm-bugs
mailing list