[comp.lang.c++] Constant Class Array Initialization

klaus@maxwell.mmwb.ucsf.edu (Klaus Fiebig) (12/05/89)

I'm having a little trouble with initializing constant class arrays while
including <iostream.h>. Cfront 2.0 gives the following error message when
compiling the little program listed below:

->  CC -g test.C
->  "test.C", line 22: internal <<AT&T C++ Translator 2.0 06/30/89>>
    error: bus error (or something nasty like that)
->  1 error
->  *** Error code 1

A listing of the test.C file:
+--------------------------------------------------------------------------
!  #include <iostream.h>    // If this line is deleted no error occurs.
!  
!  typedef const int cint;
!  cint Z = 6;
!  cint P1[Z] = { 0,1,2,3,4,5 };   cint P2[Z] = { 1,2,3,4,5,0 };
!  cint P3[Z] = { 2,3,4,5,0,1 };   cint P4[Z] = { 3,4,5,0,1,2 };
!  cint P5[Z] = { 4,5,0,1,2,3 };   cint P6[Z] = { 5,0,1,2,3,4 };
!  
!  cint N1 = 6;   cint *PP1[N1] = { P1, P2, P3, P4, P5, P6 };
!  cint N2 = 3;   cint *PP2[N2] = { P2, P4, P6 };
!  cint N3 = 2;   cint *PP3[N3] = { P1, P5 };
!  
!  class foo {
!    public:
!      cint **t;
!      int    n;
!             foo(cint **tt,int nn)    {  t=tt; n=nn;};
!            ~foo()                         {   };
!  };
!  
!  //  Const foo-array initialization:  (The next line is line 22)
!  const foo test[] = { foo(PP1,N1), foo(PP2,N2), foo(PP3,N3) };
!  
!  main() { int i = 0; i = i+1; }      // Just some scrap
+--------------------------------------------------------------------------  

It would be great if any of you gurus out there could tell me what I'm doing
wrong.


--
Klaus Fiebig, Dep. Pharmaceutical Chemistry, UC San Francisco, USA
(ARPA) klaus@maxwell.mmwb.ucsf.edu
(UUCP) /ucbvax.berkeley.edu!maxwell.mmwb.ucsf.edu!klaus
(BITNET) klaus@ucsfccb.BITNET or klaus@ucsfcgl.BITNET
--