home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 17964 < prev    next >
Encoding:
Text File  |  1992-12-14  |  1.3 KB  |  40 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!polstra!jdp
  3. From: jdp@polstra.uucp (John Polstra)
  4. Subject: Initialization {} of Aggregates with Static Members
  5. Message-ID: <BzA5oG.Bwu@polstra.uucp>
  6. Organization: Polstra & Co., Inc., Seattle, WA
  7. Date: Tue, 15 Dec 1992 03:00:15 GMT
  8. Lines: 30
  9.  
  10. I'd like some opinions on something that the ARM doesn't seem to address
  11. directly:
  12.  
  13.     struct X {
  14.     int a;
  15.     static int b;
  16.     int c;
  17.     };
  18.  
  19.     X foo = { 1, 3 };
  20.  
  21. I believe that this is legal, and that foo.a and foo.c should get
  22. the values 1 and 3, respectively.  Static member b should remain
  23. uninitialized by the code shown here; it would have to be defined
  24. exactly once elsewhere in the program.
  25.  
  26. ARM section 8.4.1 doesn't say such cases are illegal, but it doesn't really
  27. say what to do about them either.
  28.  
  29. Cfront, High C/C++, Microsoft C++ 7.0 seem to agree with me.  Furthermore,
  30. the class library provided by Microsoft relies on this behavior.  G++ 2.3.2
  31. for i386-att-sysv4 generates bad stuff that causes the assembler to become
  32. indignant.
  33.  
  34. Comments and/or ARM citations, anyone?
  35. -- 
  36.    John Polstra                              polstra!jdp@uunet.uu.net
  37.    John D. Polstra & Co., Inc.                  ...!uunet!polstra!jdp
  38.    Seattle, Washington USA   Phone (206) 932-6482, FAX (206) 935-1262
  39.    "Self-knowledge is always bad news."                 -- John Barth
  40.