Topic: On LWG issue 369 (io stream objects and static ctors)


Author: ruslan@vr1.spb.ru ("Ruslan Abdikeev")
Date: Wed, 15 Jan 2003 18:29:40 +0000 (UTC)
Raw View
Hi,

I have one remark on LWG issue 369
(http://std.dkuug.dk/jtc1/sc22/wg21/docs/lwg-active.html#369).
It seems like the intent of DR was misunderstood.

It doesn't matter, whether ios_base::Init is used or not.

What does matter, is the explicit and unsupported _non-normative_ claim:
   "Constructors and destructors for static objects can access these [standard iostream]
    objects to read input from stdin or write output to stdout or stderr"
   (27.3/2 footnote 265 [lib.iostream.objects]).

It is _non-normative_, and it is _not_ supported by the normative text of standard.
The resolution I proposed works with the existing ios_base::Init magic.

Actually, it is enough either to make this claim normative or to remove it entirely.

In short, we need some support to say that the following code is either correct or not:

    #include <iostream>
    #include <ostream>

    struct A
    {
        A() { std::cout << "Hello, world!" << std::endl; }
      ~A() { std::cout << "Goodbye, cruel world!" << std::endl; }
    };
    A a;

    int main() {}

If the claim in footnote was normative, we could say: Yes, it is legal C++.
If it was removed, we could say:
   No, only destructor is legal (27.3/2).
   Constructor is not guaranteed to work.

Currently, we have to rely on non-normative footnote.

Thank you in advance,

Kind regards,
Ruslan Abdikeev


---
[ 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                       ]