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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to