home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11234 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.1 KB  |  35 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: ztc 3.0 bug Ternary operator & chars
  5. Message-ID: <1992Jul21.162222.9895@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <1992Jul21.070508.3913@news.uni-stuttgart.de>
  8. Date: Tue, 21 Jul 1992 16:22:22 GMT
  9. Lines: 24
  10.  
  11. LANG@129.69.123.1 (MARTIN LANG) writes:
  12.  
  13. >This behavior is not a bug. The ternary operator evaluates arithmetic 
  14. >expressions. Your character constants are handled as expressions and
  15. >typecasted. That is the standard. (see ARM page 78)
  16.  
  17. It really is a bug.  The code in question looked like this:
  18.  
  19.     cout << (expr) ? '1' : '2';
  20.  
  21. The original printing of the ARM had the old C rule about promotion
  22. of the 2nd and 3rd expressions; this was an error.  Check a later
  23. printing, which you can identify by "Reprinted with corrections"
  24. appearing near the bottom of the copyright page.
  25.  
  26. Page 78, second paragraph, should say
  27.  
  28. "... if they are of the same type the result is of that type; ..."
  29.  
  30. This means that "1" or "2" should be printed, not "49" or "50".
  31. -- 
  32.  
  33. Steve Clamage, TauMetric Corp, steve@taumet.com
  34. Vice Chair, ANSI C++ Committee, X3J16
  35.