home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / gnu / gcc / bug / 2157 < prev    next >
Encoding:
Text File  |  1992-08-20  |  1.0 KB  |  48 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!inp.nsk.SU!lopatin
  3. From: lopatin@inp.nsk.SU (LOPATIN)
  4. Subject: Init of static members inside class def
  5. Message-ID: <199208201131.AA19238@inpbox.inp.nsk.su>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Thu, 20 Aug 1992 19:34:00 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 35
  12.  
  13.     I admire how your gcc 2.1 works on my DECstation 5000/200 (Ultrix 4.2),
  14. but it seems to be erroneous not to reject initialization of the static member
  15. inside class definition. Let me illustrate it by example:
  16.  
  17. [ 191 > cat one.C
  18. #include <iostream.h>
  19.  
  20. struct item {
  21.     static int y = 1;
  22. };
  23.  
  24. main(){
  25.     item x;
  26.     cout << x.y <<"\n";
  27. }
  28.  
  29. [ 192 > cat two.C
  30. struct item {
  31.     static int y;
  32. };
  33.  
  34. int item::y = 2;
  35.  
  36. [ 193 > g++ one.C two.C
  37. [ 194 > a.out
  38. 2
  39.  
  40.     For those who only red the first edition of Stroustrup's book
  41. it is not obvious that "one.C" is invalid,  so it is very suitable to
  42. report error on this, like Borland C++ does.
  43.   
  44.     Sincerely yours, Sergei V.Lopatin.
  45.  
  46.  
  47.  
  48.