[LLVMbugs] [Bug 9968] New: False positive "unused variable '__range'" with ranged for loop in template
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri May 20 08:32:50 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9968
Summary: False positive "unused variable '__range'" with ranged
for loop in template
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++0x
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jonathan.sauer at gmx.de
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
The following program results in a warning when compiled with -Wunused:
template <typename T>
struct Vector {
void doIt()
{
for (auto& e : elements)
(void) e;
}
T elements[10];
};
int main(int, char**)
{
Vector<int> vector;
vector.doIt();
}
This results in:
$ clang -std=c++0x -fsyntax-only -Wunused clang.cpp
clang.cpp:7:18: warning: unused variable '__range' [-Wunused-variable]
for (auto& e : elements)
^
clang.cpp:18:9: note: in instantiation of member function 'Vector<int>::doIt'
requested here
vector.doIt();
^
1 warning generated.
clang generates correct code for the loop. It is just the warning that is
wrong.
It also only happens if the loop's "__range" variable is dependent on the
template parameter(s).
My clang version:
$ clang --version
clang version 3.0 (trunk 131126)
Target: x86_64-apple-darwin10.7.0
Thread model: posix
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list