home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!darkstar.UCSC.EDU!daniel
- From: daniel@cse.ucsc.edu (Daniel R. Edelson)
- Newsgroups: comp.std.c++
- Subject: Initialization of const dynamic objects
- Date: 6 Nov 1992 22:13:04 GMT
- Organization: University of California, Santa Cruz (CE/CIS Boards)
- Lines: 27
- Distribution: world
- Message-ID: <1deqlgINNmc0@darkstar.UCSC.EDU>
- NNTP-Posting-Host: oak.ucsc.edu
-
-
- Section 7.1.6 contains the following statement:
-
- ``Unless explicitly declared extern, a const
- object does not have external linkage and
- must be initialized.''
-
- Does that prohibit the following code?
-
- new const int;
-
- This allocates an uninitialized const object.
- Seems like this should be explicitly prohibited (assuming
- there's no constructor, of course.) Is it?
-
- Incidently, section 5.3.3 says:
-
- ``If [a new-initializer is] not [present], the object
- will start out with an unspecified value.''
-
- Thus, an unitialized const dynamic object has and keeps
- forever an unspecified value. This should be prohibited.
-
- None of the compilers I tested detected this error.
-
- Daniel Edelson
-
-