Re: basic_ios::init: multiple call standard conform?
kanze_at_gabi-soft.fr
Date: 02/14/05
- Next message: Shivamm: "Please refer resources or Som Specific Book 4 Embedded VC++"
- Previous message: William DePalo [MVP VC++]: "Re: Learning the win32 API"
- In reply to: P.J. Plauger: "Re: basic_ios::init: multiple call standard conform?"
- Next in thread: P.J. Plauger: "Re: basic_ios::init: multiple call standard conform?"
- Reply: P.J. Plauger: "Re: basic_ios::init: multiple call standard conform?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 14 Feb 2005 12:17:15 CST
P.J. Plauger wrote:
> "helmut zeisel" <zei2003d@liwest.at> wrote in message
> news:1108101599.164388@news.liwest.at...
> > The code below causes a memory leak on Microsoft Visual C++
> > .NET 2003, but works fine with GCC 3.3.3 (cygwin
> > special). If I compile with -DSINGLE_BASIC_IOS_INIT, the
> > memory leak disappears.
> > It seems that trhe problem comes from calling
> > basic_ios::init twice, in particular via std::ios(this) and
> > via std::ostream(this). What does the standard say: is it
> > allowed to call basic_ios::init twice? What compiler is
> > standard conform, what code version is standard conform?
> The purpose of basic_ios::init is to properly initialize the
> object *after* you construct it, *before* you use it, and most
> certainly *before* you destroy it. Since all members of the
> constructed object are perforce uninitialized, there is no way
> to tell whether you've already called basic_ios::init for the
> second time. (Yes, I'm sure that many of us can contrive
> *some* way to tell, but not one with practical utility
> commensurate with its cost.)
> So I think it's a reasonable interpretation of the C++
> Standard that you should not call basic_ios::init twice for
> the same object.
So how do you avoid calling it twice in a bidirectional stream,
which inherits from both istream and ostream? The only
constructor for istream calls ios::init, and the only
constructor for ostream also calls ios::init.
Read literally, in fact, it would seem that the standard
requires basic_iostream to call basic_ios::init twice. Not that
there's really any way a conforming program could tell. (Read
literally, of course, there are a lot of wierd things in §27.)
--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
---
[ 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 ]
- Next message: Shivamm: "Please refer resources or Som Specific Book 4 Embedded VC++"
- Previous message: William DePalo [MVP VC++]: "Re: Learning the win32 API"
- In reply to: P.J. Plauger: "Re: basic_ios::init: multiple call standard conform?"
- Next in thread: P.J. Plauger: "Re: basic_ios::init: multiple call standard conform?"
- Reply: P.J. Plauger: "Re: basic_ios::init: multiple call standard conform?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|