Article View: comp.std.c
Article #4490Re: Help with tree
From: Chris Torek
Date: Fri, 15 Dec 1995 19:03
Date: Fri, 15 Dec 1995 19:03
37 lines
1948 bytes
1948 bytes
(I posted and then cancelled a followup that was meant to be mailed;
in my morning low-blood-sugar stupor I used `F' instead of `R'. :-)
However, there is one relevant point I wanted to bring up...)
In article <4aqgq5$53f@newsbf02.news.aol.com> Brutii <brutii@aol.com>
posts something mostly irrelevant to the C standard, but includes the
following function:
>np copyTree(np *pp){
>np qq;
> if (pp != NULL){
> copyTree(&(*pp)->right);
> insert(&qq, (*pp)->num);
> copyTree(&(*pp)->left);
> }
>return qq;
>}
This function recurses endlessly if pp != NULL (and has undefined
behavior if pp == NULL since qq is never initialized). I looked
for any sort of limit on recursion depth and found nothing. Section
2.2.4 (5.2.4 in ISO?) says essentially nothing about the runtime
environment. We know that at least one program containing one
32767-byte object must be accepted at compile time (in a hosted
environment), but do we have any guarantees or limits on recursion
depth? If I write an otherwise strictly conformant program that
recurses anywhere from one to ten million times, under which
failure(s), if any, can I claim to have found a non-conformant
system? Section 3.3.2.2 guarantees me recursive calls, so what,
if anything, makes (say) the 428th special when it fails?
(This is similar to the usual question about malloc(), but at least
malloc() can return NULL when it runs out of space. We have no
such luxury for recursion.)
--
In-Real-Life: Chris Torek, Berkeley Software Design Inc
El Cerrito, CA Domain: torek@bsdi.com +1 510 234 3167
Technical Details
Message-ID:
<4asgpq$280@elf.bsdi.com>Path:
arc1-ca.pugleaf.net!cs.umd.edu!not-for-mailReferences:
<4aqgq5$53f@newsbf02.news.aol.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!cs.umd.edu!not-for-mail From: torek@elf.bsdi.com (Chris Torek) Newsgroups: comp.std.c Subject: Re: Help with tree Date: 15 Dec 1995 11:03:22 -0800 Organization: Berkeley Software Design, Inc. Message-ID: <4asgpq$280@elf.bsdi.com> References: <4aqgq5$53f@newsbf02.news.aol.com> Reply-To: torek@bsdi.com NNTP-Posting-Host: elf.bsdi.com