According to http://en.cppreference.com/w/cpp/language/type , arrays of unknown bound are incomplete types and function definitions are only allowed with arguments of complete types.
Well, consider the following code:
#include <iostream>
using namespace std;
void f(int t[])
{
cout << t[2] << endl;
}
int main()
{
int tab[5] = {1,2,3,4,5};
f(tab);
}
To my understanding, int t[]
is an array of unknown bound. Therefore no argument of such type should appear within the definition of function f
, and the above code should be illegal.
Yet both clang http://melpon.org/wandbox/permlink/IqOXuXBqIsJSJLOr and gcc http://melpon.org/wandbox/permlink/8TKWq3UTP5sNC8rJ accept this code. Why?