home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / c / 3303 < prev    next >
Encoding:
Text File  |  1992-12-31  |  1.2 KB  |  37 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!paladin.american.edu!gatech!usenet.ins.cwru.edu!ncoast!brown
  3. From: brown@NCoast.ORG (Stan Brown)
  4. Subject: Re: pointer comparisons
  5. Organization: Oak Road Systems, Cleveland Ohio USA
  6. Date: Thu, 31 Dec 1992 13:30:35 GMT
  7. Message-ID: <C04LIz.3DG@NCoast.ORG>
  8. References: <1hsdg8INN5jm@urmel.informatik.rwth-aachen.de>
  9. Lines: 26
  10.  
  11. In article <1hsdg8INN5jm@urmel.informatik.rwth-aachen.de> berg@physik.tu-muenchen.de (Stephen R. van den Berg) writes:
  12. >What about the following program:     [of which I show only the salient parts]
  13. >void*a,*b;
  14. >
  15. >main()
  16. >{ int i;  /* initial assignment deleted */
  17. >  a=malloc(1); b=malloc(1);
  18. >  i+=a>b; 
  19. >  printf("%d\n",i);
  20. >  return i;
  21. >}
  22. >---------------------------------------
  23. >
  24. >Is this program *always* required to print or return "3"?
  25.  
  26. I believe this program is not obligated to print or return _anything_,
  27. but may, in John Woods's happy phrase, "cause demons to fly out of your
  28. nose."
  29.  
  30. Comparing pointers that point to different objects leads to an undefined
  31. result.  See ANSI section 3.3.8 (ISO 6.3.8, I believe).
  32. -- 
  33. Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
  34. Cleveland, Ohio, USA
  35.  
  36. What's a question that contains the word 'cantaloupe' for no apparent reason?
  37.