[LLVMbugs] [Bug 11601] New: Range-based for cannot iterate over explicitly typed function pointers
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Dec 16 18:51:43 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=11601
Bug #: 11601
Summary: Range-based for cannot iterate over explicitly typed
function pointers
Product: clang
Version: 3.0
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++0x
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: ainsaar at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Consider the following code (test.cpp) trying different ways of iterating over
an array of function pointers.
/////////////////////////////////////////
void v() {}
int main() {
void (*vv[])() = {v, v, v};
typedef void (*type)();
for (type i : vv) i();
for (decltype(*vv) i : vv) i();
for (auto i : vv) i();
for (void (*i)() : vv) i(); // Does not compile
return 0;
}
/////////////////////////////////////////
Clang++ 3.0 gives the following errors:
$ clang++ test.cpp -std=c++11 -Wall -pedantic
test.cpp:10:17: error: use of undeclared identifier 'i'
for (void (*i)() : vv) i(); // Does not compile
^
test.cpp:10:26: error: expected ';' in 'for' statement specifier
for (void (*i)() : vv) i(); // Does not compile
^
test.cpp:10:28: error: use of undeclared identifier 'i'
for (void (*i)() : vv) i(); // Does not compile
^
3 errors generated.
I think it should be possible to iterate over an array of function pointers
using a range-based for loop with an iterator whose type has been spelled out.
--
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