home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 12957 < prev    next >
Encoding:
Text File  |  1992-08-26  |  1.9 KB  |  75 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!usc!sdd.hp.com!elroy.jpl.nasa.gov!nntp-server.caltech.edu!cithe503.cithep.caltech.edu!panetta
  3. From: panetta@cithe503.cithep.caltech.edu (James Panetta)
  4. Subject: Strange behavior with gcc 2.0 (bug?)
  5. Message-ID: <1992Aug27.075945.21285@cco.caltech.edu>
  6. Sender: news@cco.caltech.edu
  7. Nntp-Posting-Host: cithe503.cithep.caltech.edu
  8. Reply-To: panetta@cithe501.cithep.caltech.edu.UUCP (James Panetta)
  9. Organization: California Institute of Technology, Pasadena
  10. References: <BtMGyz.52A@me.utoronto.ca> <MCGRANT.92Aug26232210@rascals.stanford.edu> <9224017.22289@mulga.cs.mu.OZ.AU>
  11. Date: Thu, 27 Aug 1992 07:59:45 GMT
  12. Lines: 61
  13.  
  14.  
  15. Folks-
  16.    When running g++ on an IBM RS/6000 I come across the following 
  17. strange behavior.  (gcc V2.2.2 from version.c)
  18.     I've discovered an irritating problem with the following program:
  19.  
  20. /*********************************************************************/
  21. /*
  22.  *        File: really_FUBAR.cc
  23.  *        Description: demonstrates a possible bug?
  24.  *
  25.  */
  26. #include <iostream.h>
  27.  
  28. int main(void)
  29. {
  30.     unsigned i;
  31.  
  32.     i = 7U;
  33.     cout << (long double)i <<endl;
  34.     cout << i << " " << i << endl;
  35.     cout << (long double)i << " " << (long double)i << endl;
  36.     cout << i << " " << (long double)i << endl;
  37.     cout << (long double)i << " " << i << endl;
  38. }
  39.  
  40. /*********************************************************************/
  41.  
  42. The output is:
  43. 7
  44. 7 7
  45. 7 1.12722e+09
  46. 7 1.12722e+09
  47. 7 7
  48.  
  49.  
  50. This output persists when _i_ is typecast to double also.  This would be
  51. only a minor annoyance if this behavior didn't persist across function
  52. call boundaries.  i.e.:
  53.  
  54. foo(i,(long)i);
  55.  
  56. inside foo:
  57.  
  58. foo(unsigned bar, long bazz){
  59.  
  60.     cout << bar << endl;
  61.     cout << bazz << endl;
  62. }
  63.  
  64. generates (for i=7U):
  65.  
  66. 7
  67. 1.12722e+09
  68.  
  69. Any solutions?
  70. Jim Panetta
  71. -- 
  72. Panetta@cithex.caltech.edu          :-(     A witty saying proves nothing.
  73. Panetta@cithex.bitnet               :-|
  74. Panetta@cithe503.cithep.caltech.edu :-)                             Voltaire
  75.