Topic: No ios_base::Init object before main starts?
Author: RaoulGough@yahoo.co.uk ("Raoul Gough")
Date: Wed, 12 Feb 2003 20:08:06 +0000 (UTC) Raw View
Consider the following code:
#include <ios>
int main () {
std::ios_base::Init x;
}
According to 27.3/2, the standard streams like cout are constructed
before main begins execution, even if no Init object exists. According
to 27.4.2.1.6, the first ios_base::Init constructor call constructs
the standard streams. These requirements seem to be contradictory,
unless there is guaranteed to be at least one Init object created
*before* main begins execution (in which case, where is this
requirement stated, and why is there the additional wording in 27.3/2
covering the case that there isn't one?).
27.3/2 contains the following:
"The objects are constructed, and the associations are established at
some time prior to or during first time an object of class
basic_ios<charT,traits>::Init is constructed, and in any case before
the body of main begins execution."
Also, in the absence of any static Init object, there doesn't seem to
be any reason for std::cout to be flushed properly on program shut
down.
Raoul Gough.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]