home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13349 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.8 KB  |  68 lines

  1. Path: sparky!uunet!van-bc!rsoft!agate!usenet.ins.cwru.edu!gatech!bloom-beacon!eru.mt.luth.se!lunic!sunic!kth.se!news.kth.se!RICHARD
  2. From: RICHARD@NIXON.ttt.kth.se
  3. Newsgroups: comp.lang.c++
  4. Subject: Strange error. GCC 2.2.2
  5. Message-ID: <RICHARD.92Sep6170946@NIXON.ttt.kth.se>
  6. Date: 6 Sep 92 16:09:46 GMT
  7. Sender: usenet@kth.se (Usenet)
  8. Organization: Department of TeleTransmission Theory
  9. Lines: 56
  10. Nntp-Posting-Host: nixon.ttt.kth.se
  11.  
  12. I have the following code:
  13.  
  14.     struct foo
  15.     {
  16.       char *s;
  17.       foo(char *x)    { s=x; }
  18.     };
  19.  
  20.     struct bar
  21.     {
  22.       foo * v;
  23.       bar ()    { v=0; }
  24.       bar (foo * x) { v=x; }
  25.       bar & operator = (bar & x) { v=x.v; return *this; }
  26.     };
  27.  
  28.     struct cookie
  29.     {
  30.       foo * v;
  31.       cookie ( foo * x) { v=x; }
  32.     };
  33.  
  34.     cookie cat(&foo("apabepa"));
  35.  
  36.     struct cake
  37.     {
  38.       bar v;
  39.       cake ( bar & x ) { v=x; }
  40.     };
  41.  
  42.     cake monkey(&foo("haha")); // <---- GCC barfs here
  43.  
  44. At the place where gcc barfs, it is cc1plus with gives me a fatal signal 11.
  45.  
  46. It is fixed by spliting that line with:
  47.  
  48.     foo monkey_dummy("haha");
  49.     cake monkey(&monkey_dummy);
  50.  
  51. Details: note that the argument passed to the cake constructor is a foo *,
  52. and thus is converted to bar with the constructor bar(foo *).
  53.  
  54. The definition of cat works like charms.
  55.  
  56. What I would like to know is if the contruction GCC barfs on is legal (and
  57. thus, there is a bug in GCC), or if I tried to do something illegal.
  58.  
  59. I do not have the ARM, so those who have, please tell me.
  60.  
  61. --
  62. !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
  63. ! Richard Levitte, System manager       ! tel: int+46-8-790 64 23           !
  64. ! Royal Institute of Technology         ! fax: int+46-8-791 76 54           !
  65. ! Department of Teletransmition Theory  ! Internet: richard@ttt.kth.se      !
  66. ! S-100 44 Stockholm, Sweden            !                                   !
  67. !---------------------------------------------------------------------------!
  68.