g++ rejects declaration of reference to array?
Richard Guenther
rguenth@tat.physik.uni-tuebingen.de
Fri Oct 17 13:24:00 GMT 2003
Hi!
Consider:
template <class F>
void foo(const F &x);
void foo2(int[3] const&);
void bar()
{
int a[3];
foo(a);
foo2(a);
}
which yields with gcc 3.4:
bellatrix:~/src/tests$ g++-3.4 -Wall -c refar.cpp
refar.cpp:4: error: variable or field `foo2' declared void
refar.cpp:4: error: expected primary-expression
refar.cpp: In function `void bar()':
refar.cpp:10: error: `foo2' cannot be used as a function
but the foo() gets mangled to _Z3fooIA3_iEvRKT_ which demangles to
void foo<int[3]>(int[3] const&)
so the declaration of foo2 should be indeed correct? Also where would I
place the identifier in the declaration? int[3] const &I does not work
either.
Sect. 8.3.2 of the C++ standard is also not very helpful on this.
Confused,
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
More information about the Gcc
mailing list