home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / gcc / bug / 3246 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.6 KB  |  129 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cs.ucl.ac.uk!G.Joly
  2. From: G.Joly@cs.ucl.ac.uk (Gordon Joly)
  3. Newsgroups: gnu.gcc.bug
  4. Subject: Internal error in cc1plus (signal 4) - simple string class example.
  5. Date: 25 Jan 1993 21:14:15 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 116
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-gcc@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <9301251819.AA08523@life.ai.mit.edu>
  12.  
  13. On a SUN4, SunOS 4.1.1, gcc 2.3.3 (built with 2.3.1) libg++ 2.3, & SUN
  14. libc.so.1.6.1 
  15.  
  16.  
  17. #include<iostream.h>
  18. #include<String.h>
  19.  
  20. // A very simple class consisiting of a String, int pair
  21.  
  22. class Collection
  23. {
  24.     String name;
  25.     int id_number;
  26. public:
  27.     Collection(String& s, int p):name(s),id_number(p){}
  28.  
  29.     // constructor does nothing exciting
  30.  
  31.     operator String(){return name;}
  32.  
  33.     // conversion operator similarly dull
  34.  
  35.     ostream& print(ostream& a)
  36.         {
  37.             a<<"name: "<<name<<"\n"
  38.                 <<"id_number: "<<id_number<<"\n";
  39.             return a;
  40.         }
  41.  
  42.     // output
  43.  
  44.     String& GetName()
  45.         {
  46.             return name;
  47.         }
  48.     // .. and access
  49. };
  50.  
  51. // a trivial example function ... but could just as well have been
  52. // a class member function for this problem
  53.  
  54. void DoSomething(String& s)
  55. {
  56.     cout<<"ya boo sucks: "<<s<<"\n";
  57. }
  58.  
  59. int main()
  60. {
  61.     Collection guanaco("llama", 42);
  62.  
  63. //    DoSomething(guanaco.GetName());        // This works fine
  64.  
  65.     DoSomething(guanaco);            // Compiler never exits...
  66.  
  67.     guanaco.print(cout)<<"\n";
  68.  
  69.     return 0;
  70. }
  71.  
  72. /*
  73.  
  74. ----------------------------------------------------- 
  75.  
  76.  
  77. Above is an example of code that compiles without error on the
  78. departmental compiler and causes 2.3.3 to hang.
  79.  
  80. NB 2.3.3 copes if the commented DoSomething() invocation is used
  81. instead.
  82.  
  83. I think there may be some other bugs in the error recovery department
  84. i.e. a parse error gets reported sometimes and the compiler hangs. But
  85. I will try to provide a separate example of this.
  86.  
  87.  
  88.  
  89. D.Critchley
  90. -------------------------------------------------------------
  91.  
  92. */
  93.  
  94.  
  95. Runs with output:
  96.  
  97. porridge:gjoly/c++/2.x[76] a.out
  98. ya boo sucks: llama
  99. name: llama
  100. id_number: 42
  101.  
  102. porridge:gjoly/c++/2.x[77]
  103.  
  104.  
  105. Snapshot with "error"
  106.  
  107.   PID USERNAME PRI NICE   SIZE   RES STATE   TIME   WCPU    CPU COMMAND
  108.  9845 gjoly     82    0 32424K 14256K run     1:17 74.04% 73.83% cc1plus
  109.  
  110.  
  111. Followed by
  112.  
  113. porridge:gjoly/c++/2.x[79]
  114. /cs/research/coside/local/croissant/bin/gcc: Internal compiler
  115. error: program cc1plus got fatal signal 4
  116.  
  117. porridge:gjoly/c++/2.x[79]
  118. porridge:gjoly/c++/2.x[79]
  119.  
  120.  
  121. Gordon.
  122.  
  123.  
  124. Gordon Joly      Phone  +44 71 387 7050 ext 3703      FAX  +44 71 387 1397
  125. Internet: G.Joly@cs.ucl.ac.uk        UUCP: ...!{uunet,uknet}!ucl-cs!G.Joly
  126. Computer Science, University College London, Gower Street, LONDON WC1E 6BT
  127.  
  128.  
  129.