home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / std / c / 3065 < prev    next >
Encoding:
Text File  |  1992-11-24  |  1005 b   |  31 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggert
  3. From: eggert@twinsun.com (Paul Eggert)
  4. Subject: Re: Return values from recursive function
  5. Message-ID: <bknJSeCZ@twinsun.com>
  6. Sender: usenet@twinsun.com
  7. Nntp-Posting-Host: farside
  8. Organization: Twin Sun, Inc
  9. References: <1erqs4INN7aa@zeppo.uccs.edu>
  10. Date: Tue, 24 Nov 1992 03:08:27 GMT
  11. Lines: 18
  12.  
  13. dbbergac@sanluis (Dave Bergacker) writes:
  14.  
  15. >int streq(const char *s1, const char *s2)
  16. >{
  17. >  if ( !*s1 || ( *s1 != *s2 )) return *s1 - *s2;
  18. >  else streq(++s1,++s2);
  19. >}
  20.  
  21. >Does ANSI specify anything about this behavior?
  22.  
  23. Yes.  The C Standard says the behavior is undefined.
  24.  
  25. >This code worked on Borlands TC (version unknown) and gcc version 2.2.2.
  26.  
  27. ``Undefined'' means the implementation can do anything it pleases -- it
  28. can even do what the programmer meant!  An implementation need not
  29. diagnose this error.  But you should tell your students to use their
  30. compilers' debugging options; e.g. `gcc -Wall' diagnoses this error.
  31.