[Bug c++/56794] New: C++11 Error in range-based for with parameter pack array

bisqwit at iki dot fi gcc-bugzilla@gcc.gnu.org
Sun Mar 31 21:07:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56794

             Bug #: 56794
           Summary: C++11 Error in range-based for with parameter pack
                    array
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bisqwit@iki.fi


G++ 4.7.2 and 4.8.0 give the following error message for the for-loop in below
code:

tmp.cc:10:17: error: range-based 'for' expression of type 'const int []' has
incomplete type

On G++ 4.6.3 (and Clang++), it compiles fine. Regression?


template<int... values>
static void Colors()
{
    static const int colors[] = { values... };
    // ^ This version passes in G++ 4.6 and Clang++ 3.0, fails in G++ 4.7 and
4.8

    //static const int colors[sizeof...(values)] = { values... };
    // ^This passes in all of them

    for(auto c: colors) { }
    // ^ This line is the one that gets the error message
}

int main()
{
    Colors<0,1,2> ();
}



More information about the Gcc-bugs mailing list