-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
| Bugzilla Link | 33839 |
| Resolution | FIXED |
| Resolved on | Dec 05, 2017 14:39 |
| Version | unspecified |
| OS | Linux |
| Blocks | #33840 |
| CC | @bebuch,@zygoloid,@stephenhines,@tstellar |
| Fixed by commit(s) | r314733 r319847 |
Extended Description
Range-based iteration of templated variable type produces a bogus unused-variable warning. Note that the same variant without the template (non_template_print) doesn't have a warning.
$ cat warning.cpp
#include
#include
#include
template
void template_print(std::vector<std::pair<std::string, T>>& files_and_parameters) {
for (const auto& [file, parameter] : files_and_parameters) {
std::cout << file << " " << parameter << std::endl;
}
}
void non_template_print(std::vector<std::pair<std::string, int>>& files_and_parameters) {
for (const auto& [file, parameter] : files_and_parameters) {
std::cout << file << " " << parameter << std::endl;
}
}
void print() {
std::vector<std::pair<std::string, int>> files_and_gids = {
std::make_pair("s1", 1),
std::make_pair("s2", 2),
std::make_pair("s3", 3)
};
template_print(files_and_gids);
non_template_print(files_and_gids);
}
$ clang++ -c -std=c++1z -Wall -Wextra -o warning.o warning.cpp
warning.cpp:7:22: warning: unused variable '' [-Wunused-variable]
for (const auto& [file, parameter] : files_and_parameters) {
^
warning.cpp:25:5: note: in instantiation of function template specialization 'template_print'
requested here
template_print(files_and_gids);
^
1 warning generated.