This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/53211] range-based 'for' expression of type 'const int []' has incomplete type
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 03 May 2012 13:17:27 +0000
- Subject: [Bug c++/53211] range-based 'for' expression of type 'const int []' has incomplete type
- Auto-submitted: auto-generated
- References: <bug-53211-4@http.gcc.gnu.org/bugzilla/>
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,
^