typeid bug with arrays of const

Valentin Bonnard bonnardv@pratique.fr
Mon Jan 11 10:06:00 GMT 1999


const in typedef for arrays work, except when using typeid: 

croiseur-/tmp $ < a.cc 
#include <iostream>
#include <typeinfo>

int main ()
{
  typedef int i5[5];
  typedef const int ci5[5];

  ci5 c;
//  c[3] = 3; // ok: error here

  std::cout << typeid (i5).name () << endl;
  std::cout << typeid (ci5).name () <<  endl;
  std::cout << (typeid (i5) == typeid (ci5)) << endl;
}
croiseur-/tmp $ a.out 
A5_i
A5_i // const ignored
1    // same typeid !
croiseur-/tmp $ egcs -v
Reading specs from
/usr/local/util/packages/egcs-050798/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.45/specs
gcc version egcs-2.91.45 19980704 (gcc2 ss-980609 experimental)

-- 

Valentin Bonnard                mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://pages.pratique.fr/~bonnardv/



More information about the Gcc-bugs mailing list