home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / std / cplus / 1506 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  1.1 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!darkstar.UCSC.EDU!daniel
  2. From: daniel@cse.ucsc.edu (Daniel R. Edelson)
  3. Newsgroups: comp.std.c++
  4. Subject: Initialization of const dynamic objects
  5. Date: 6 Nov 1992 22:13:04 GMT
  6. Organization: University of California, Santa Cruz (CE/CIS Boards)
  7. Lines: 27
  8. Distribution: world
  9. Message-ID: <1deqlgINNmc0@darkstar.UCSC.EDU>
  10. NNTP-Posting-Host: oak.ucsc.edu
  11.  
  12.  
  13. Section 7.1.6 contains the following statement:
  14.  
  15.     ``Unless explicitly declared extern, a const
  16.     object does not have external linkage and
  17.     must be initialized.''
  18.  
  19. Does that prohibit the following code?
  20.  
  21.     new const int;
  22.  
  23. This allocates an uninitialized const object. 
  24. Seems like this should be explicitly prohibited (assuming
  25. there's no constructor, of course.) Is it?
  26.  
  27. Incidently, section 5.3.3 says:
  28.  
  29.     ``If [a new-initializer is] not [present], the object
  30.     will start out with an unspecified value.''
  31.  
  32. Thus, an unitialized const dynamic object has and keeps
  33. forever an unspecified value. This should be prohibited.
  34.  
  35. None of the compilers I tested detected this error.
  36.  
  37. Daniel Edelson
  38.  
  39.