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]

array decays too fast.


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 *'


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