🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++
Article #235

Re: bastard programs

#235
From: T.Day
Date: Thu, 07 Dec 1989 11:52
23 lines
1543 bytes
From: Tim Day <T.Day@uk.ac.ucl.cs>

Something to watch out for:
It's quite possible to write e.g stdout << "foobar" and similar things by
accident.  The type conversion attempts to convert stdout to an ostream 
(possible using the ostream constructors); there is be no warning message, 
but the program usually bombs in all sorts of strange places if you write
 stdout << "a" << "b"
as the newly constructed ostream goes out of scope before the second
operator<< is called; (except that it hangs around on the stack long
enough to look like it had worked and/or screws up the stack to mislead
the debugger).

I suspect mixing cerr and stderr is asking for trouble.  Either use one or
the other, or perhaps derive your own ostream class and replace all the
operator<< routines with stuff to access FILE*s (or cerr specifically)
safely using fprintf.

+-----------------------------------------------------------------------------+
Tim Day                           | Meet every second in life as challenge;
Department of Photogrammetry      | Respond fully to whatever happens
UCL, Gower St., London  WC1E 6BT  |  without anxiety, or complaint, or clinging
+-----------------------------------------------------------------------------+
Technical Details
Message-ID: <479@ucl-cs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!mcsun!ukc!kl-cs!nott-cs!ucl-cs!T.Day

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!mcsun!ukc!kl-cs!nott-cs!ucl-cs!T.Day
From: T.Day@ucl-cs.UUCP
Newsgroups: gnu.g++
Subject: Re: bastard programs
Message-ID: <479@ucl-cs.UUCP>
Date: 7 Dec 89 11:52:56 GMT
Sender: T.Day@ucl-cs.UUCP
Lines: 23