From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8430 invoked by alias); 11 Feb 2009 21:23:14 -0000 Received: (qmail 8421 invoked by uid 22791); 11 Feb 2009 21:23:13 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 Feb 2009 21:23:07 +0000 Received: from brahms.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by brahms.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id n1BLMgKh003112; Wed, 11 Feb 2009 22:22:42 +0100 (CET) Received: (from kettenis@localhost) by brahms.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id n1BLMf8q000100; Wed, 11 Feb 2009 22:22:41 +0100 (CET) Date: Wed, 11 Feb 2009 21:23:00 -0000 Message-Id: <200902112122.n1BLMf8q000100@brahms.sibelius.xs4all.nl> From: Mark Kettenis To: drow@false.org CC: jan.kratochvil@redhat.com, gdb-patches@sourceware.org In-reply-to: <20090211205045.GB9762@caradoc.them.org> (message from Daniel Jacobowitz on Wed, 11 Feb 2009 15:50:45 -0500) Subject: Re: [patch] Fix `return' of long/long-long results with no debuginfo References: <20090211194511.GA9324@host0.dyn.jankratochvil.net> <200902112040.n1BKdxb3028188@brahms.sibelius.xs4all.nl> <20090211205045.GB9762@caradoc.them.org> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-02/txt/msg00260.txt.bz2 > Date: Wed, 11 Feb 2009 15:50:45 -0500 > From: Daniel Jacobowitz > > On Wed, Feb 11, 2009 at 09:40:00PM +0100, Mark Kettenis wrote: > > Sorry, this is wrong. Functions without return type implicitly return int. > > I think it's a mistake to bring this rule (from K&R C, and removed in > C99) to GDB. This is a different context; it's not functions declared > without a return type in source code, but functions with an unknown > return type (and unknown source language). I disagree. I think it is the behaviour that makes the most sense in a historical context. And I have a (somewhat) vague recollection that there are debug formats or compilers where we cant distinguish between functions without a return type and functions with "unknown" return type. > Everything we pick will be wrong some of the time, but IMO "long" is > maximally useful. "long long" on 32-bit platforms is going to pick > up garbage from the next register for int or void * returns. Most > platforms with int != long will have the return register with > sizeof(long). The right solution of course is to distribute libraries with debug sumbols. But in cases where that is impossible, would it be an idea to use the type of the return value expression given by the user instead of int as a fallback? In the case at hand, "return -1" will still fail, but it would be possible to do return (void *)-1 to do what the user wanted.