This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++ rejects declaration of reference to array?
Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> writes:
> 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?
IMHO that's a bug in the demangler. It should be "const int (&)[3]".
> Also where would I place the identifier in the declaration? int[3] const
> &I does not work either.
const int (&I)[3]
>
> Sect. 8.3.2 of the C++ standard is also not very helpful on this.
"Cv-qualified references are illformed..."
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."