| Issue |
180443
|
| Summary |
[clang-tidy] some `modernize-use-auto` warnings unnecessarily limited to C++17
|
| Labels |
enhancement,
clang-tidy
|
| Assignees |
|
| Reporter |
firewave
|
```cpp
#include <map>
void f()
{
std::multimap<int, int> mm;
auto range = mm.equal_range(0);
for (std::multimap<int, int>::const_iterator I = range.first; I != range.second; ++I) {}
for (auto I = range.first; I != range.second; ++I) {}
}
```
The first loop is only reported with C++17 although it compiles using `auto` with C++11 (the second loop is the code after applying the fix-it in C++17 mode).
```
<source>:7:10: warning: use auto when declaring iterators [modernize-use-auto]
7 | for (std::multimap<int, int>::const_iterator I = range.first; I != range.second; ++I) {}
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| auto
```
C++11: https://godbolt.org/z/9TKozqhKb
C++17: https://godbolt.org/z/4541xecsE
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs