This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
g++ rejects declaration of reference to array?
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 17 Oct 2003 13:27:33 +0200 (CEST)
- Subject: g++ rejects declaration of reference to array?
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/