home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / c / 3286 < prev    next >
Encoding:
Internet Message Format  |  1992-12-30  |  2.1 KB

  1. Xref: sparky comp.std.c:3286 comp.lang.c:19017
  2. Newsgroups: comp.std.c,comp.lang.c
  3. Path: sparky!uunet!usc!elroy.jpl.nasa.gov!decwrl!deccrl!news.crl.dec.com!rdg.dec.com!uvo.dec.com!e2big.mko.dec.com!jrdzzz.jrd.dec.com!jit533.jit.dec.com!diamond
  4. From: diamond@jit533.jit.dec.com (Norman Diamond)
  5. Subject: Re: uninitialized++;
  6. Message-ID: <C02DDv.2Kw@jrd.dec.com>
  7. Sender: usenet@jrd.dec.com (USENET News System)
  8. Nntp-Posting-Host: jit533.jit.dec.com
  9. Reply-To: diamond@jit.dec.com (Norman Diamond)
  10. Organization: Digital Equipment Corporation Japan , Tokyo
  11. References: <HBF.92Dec29211517@gandalf.uio.no> <9236508.13290@mulga.cs.mu.OZ.AU>
  12. Date: Wed, 30 Dec 1992 08:39:31 GMT
  13. Lines: 26
  14.  
  15. In article <9236508.13290@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  16. >hbf@gandalf.uio.no (Hallvard B Furuseth) writes:
  17. >>Can this fail  - on some machine?  - in ANSI?
  18. >>main () { int uninitialized; uninitialized++; return 0; }
  19.  
  20. >I've redirected things to comp.std.c where hopefully someone will be able
  21.  
  22. I added comp.lang.c back to it so Mr./Ms. Furuseth will find it.
  23. On some machine, yes:  if the implementation detects overflow of signed
  24. integers, and uninitialized happens to have started at INT_MAX.  And ANSI
  25. Classic section 3.3, page 39 lines 15 to 17, allows failure for this reason:
  26. "If an exception occurs during the evaluation of an expression (that is, if
  27. the result is not mathematically defined or not in the range of representable
  28. values for its type), the behavior is undefined."
  29.  
  30. On another machine, maybe yes:  once upon a time a famous Fortran compiler
  31. helped students catch bugs by checking for things like usings uninitialized
  32. variables.  A hypothetical C implementation could try to initialize each
  33. uninitialized object to the worst possible value, in hopes of doing the same.
  34. It would be able to catch yours that way.  But consider this program:
  35.   main () { int uninitialized; uninitialized += 0; return 0; }
  36. I think this one is not allowed to fail.
  37. --
  38. Norman Diamond                diamond@jit.dec.com
  39. If this were the company's opinion, I wouldn't be allowed to post it.
  40. Pardon me?  Or do I have to commit a crime first?
  41.