home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!usc!sdd.hp.com!elroy.jpl.nasa.gov!nntp-server.caltech.edu!cithe503.cithep.caltech.edu!panetta
- From: panetta@cithe503.cithep.caltech.edu (James Panetta)
- Subject: Strange behavior with gcc 2.0 (bug?)
- Message-ID: <1992Aug27.075945.21285@cco.caltech.edu>
- Sender: news@cco.caltech.edu
- Nntp-Posting-Host: cithe503.cithep.caltech.edu
- Reply-To: panetta@cithe501.cithep.caltech.edu.UUCP (James Panetta)
- Organization: California Institute of Technology, Pasadena
- References: <BtMGyz.52A@me.utoronto.ca> <MCGRANT.92Aug26232210@rascals.stanford.edu> <9224017.22289@mulga.cs.mu.OZ.AU>
- Date: Thu, 27 Aug 1992 07:59:45 GMT
- Lines: 61
-
-
- Folks-
- When running g++ on an IBM RS/6000 I come across the following
- strange behavior. (gcc V2.2.2 from version.c)
- I've discovered an irritating problem with the following program:
-
- /*********************************************************************/
- /*
- * File: really_FUBAR.cc
- * Description: demonstrates a possible bug?
- *
- */
- #include <iostream.h>
-
- int main(void)
- {
- unsigned i;
-
- i = 7U;
- cout << (long double)i <<endl;
- cout << i << " " << i << endl;
- cout << (long double)i << " " << (long double)i << endl;
- cout << i << " " << (long double)i << endl;
- cout << (long double)i << " " << i << endl;
- }
-
- /*********************************************************************/
-
- The output is:
- 7
- 7 7
- 7 1.12722e+09
- 7 1.12722e+09
- 7 7
-
-
- This output persists when _i_ is typecast to double also. This would be
- only a minor annoyance if this behavior didn't persist across function
- call boundaries. i.e.:
-
- foo(i,(long)i);
-
- inside foo:
-
- foo(unsigned bar, long bazz){
-
- cout << bar << endl;
- cout << bazz << endl;
- }
-
- generates (for i=7U):
-
- 7
- 1.12722e+09
-
- Any solutions?
- Jim Panetta
- --
- Panetta@cithex.caltech.edu :-( A witty saying proves nothing.
- Panetta@cithex.bitnet :-|
- Panetta@cithe503.cithep.caltech.edu :-) Voltaire
-