This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
array decays too fast.
- To: egcs at cygnus dot com
- Subject: array decays too fast.
- From: Nathan Myers <ncm at nospam dot cantrip dot org>
- Date: Wed, 12 Aug 1998 20:49:03 -0700
- Newsgroups: cygnus.egcs
- Organization: http://www.cantrip.org/
In egcs-2.91.50, the type of an array decays too readily
to a pointer, so that a conversion from T to const T& fails,
and template type matching fails. (EDG-2.38 accepts this code.)
I would have expected the cast to be unnecessary, but
even EDG doesn't accept it without the cast.
Nathan Myers
egcs -c refmatch.cc
----------------------------------------
struct A { };
template <unsigned N>
unsigned f(const A (& aa)[N]) { return N; }
int main()
{
A aa[3];
typedef const A (& CAR)[3];
(CAR)aa;
return f((CAR)aa) != 3;
}
-----------------------------------------
refmatch.cc: In function `int main()':
refmatch.cc:10: converting to `A[3]' from `A *'
refmatch.cc:11: converting to `A[3]' from `A *'