🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2994

Re: Return values from recursive function

#2994
From: Paul Eggert
Date: Tue, 24 Nov 1992 03:08
18 lines
1035 bytes
dbbergac@sanluis (Dave Bergacker) writes:

>int streq(const char *s1, const char *s2)
>{
>  if ( !*s1 || ( *s1 != *s2 )) return *s1 - *s2;
>  else streq(++s1,++s2);
>}

>Does ANSI specify anything about this behavior?

Yes.  The C Standard says the behavior is undefined.

>This code worked on Borlands TC (version unknown) and gcc version 2.2.2.

``Undefined'' means the implementation can do anything it pleases -- it
can even do what the programmer meant!  An implementation need not
diagnose this error.  But you should tell your students to use their
compilers' debugging options; e.g. `gcc -Wall' diagnoses this error.
Technical Details
Message-ID: <bknJSeCZ@twinsun.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggert
References: <1erqs4INN7aa@zeppo.uccs.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggert
From: eggert@twinsun.com (Paul Eggert)
Subject: Re: Return values from recursive function
Message-ID: <bknJSeCZ@twinsun.com>
Sender: usenet@twinsun.com
Nntp-Posting-Host: farside
Organization: Twin Sun, Inc
References: <1erqs4INN7aa@zeppo.uccs.edu>
Date: Tue, 24 Nov 1992 03:08:27 GMT
Lines: 18