From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19451 invoked by alias); 26 Apr 2002 19:00:30 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 19441 invoked from network); 26 Apr 2002 19:00:28 -0000 Received: from unknown (HELO gandalf.codesourcery.com) (66.60.148.227) by sources.redhat.com with SMTP; 26 Apr 2002 19:00:28 -0000 Received: from gandalf.codesourcery.com (localhost.localdomain [127.0.0.1]) by gandalf.codesourcery.com (8.11.6/8.11.6) with ESMTP id g3QIvVL12866; Fri, 26 Apr 2002 11:57:31 -0700 Date: Fri, 26 Apr 2002 12:11:00 -0000 From: Mark Mitchell To: Chris Lattner , "gcc@gcc.gnu.org" Subject: RE: pure and const functions Message-ID: <169790000.1019847451@gandalf.codesourcery.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-SW-Source: 2002-04/txt/msg01457.txt.bz2 --On Friday, April 26, 2002 11:50:07 AM -0500 Chris Lattner wrote: > >> int fib(int n) { >> if (n==0 || n==1) return n; >> return fib(n-1) + fib(n-2); >> } > >> According to the definitions given above, this function is const, >> but not total, because it does not return for negative n. > > While this is true in a practical sense, given infinite resources, this is > certainly not the case. Assuming you had a whole lot of stack space and > bunch of time, the negative values for 'n' would wrap around to positive > values. Eventually it would get to 1 and terminate. Actually, C does not guarantee that negative values wrap around to positive values. -- Mark Mitchell mark@codesourcery.com CodeSourcery, LLC http://www.codesourcery.com