This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/53211] range-based 'for' expression of type 'const int []' has incomplete type


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-05-03
     Ever Confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-03 13:17:27 UTC ---
Confirmed, that's a bug.

It works if the array bound is given explicitly:

   const int arr[sizeof...(Args)] = {args...};


Reduced:

template<typename A, typename B>
  struct is_same { static const bool value = false; };

template<typename A>
  struct is_same<A, A> { static const bool value = true; };

template<typename... Args>
void func(Args... args) {
  int arr[] = {args...};
  static_assert(is_same<decltype(arr), int[sizeof...(Args)]>::value,
                "complete type");
}

int main() {
   func(1,2,3,4);
}


for.cc: In instantiation of 'void func(Args ...) [with Args = {int, int, int,
int}]':
for.cc:15:16:   required from here
for.cc:10:3: error: static assertion failed: complete type
   static_assert(is_same<decltype(arr), int[sizeof...(Args)]>::value,
   ^


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]