This is the mail archive of the gcc@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]

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/


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