This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][C/C++] Do not promote return arguments
- From: Andrew Haley <aph-gcc at littlepinkcloud dot COM>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: Richard Guenther <rguenther at suse dot de>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 6 Aug 2007 15:46:48 +0100
- Subject: Re: [PATCH][C/C++] Do not promote return arguments
- References: <Pine.LNX.4.64.0707051311250.24708@zhemvz.fhfr.qr> <m3y7ht38al.fsf@localhost.localdomain> <18103.7341.556783.13690@zebedee.pink> <m3lkcou45e.fsf@localhost.localdomain>
Ian Lance Taylor writes:
> Andrew Haley <aph-gcc@littlepinkcloud.COM> writes:
>
> > Ian Lance Taylor writes:
> > > Richard Guenther <rguenther@suse.de> writes:
> > >
> > > > 2007-07-05 Richard Guenther <rguenther@suse.de>
> > > >
> > > > cp/
> > > > * decl.c (start_preparsed_function): Do not promote return type.
> > > >
> > > > * c-decl.c (start_function): Do not promote return type.
> > >
> > > This is OK.
> > >
> > > Thanks.
> >
> > This is an externally visible change that causes return values not to
> > be zero- or sign-extended. This breaks code. I don't think this
> > should be done.
> >
> > See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32843 for more discussion.
>
> It's a struggle for me to imagine valid C/C++ code which is broken by
> this change.
I don't think it breaks any standard C/C++ code, but the ABI allows
C/C++ code to be called from assembler (and other languages) and
defines how return values should be promoted. It's quite proper for
assembly code to assume that return values are promoted according to
their type, and this is where the libffi breakage came from.
Also, non-portable C/C++code that assumes that short and char values
will be promoted to ints will be broken by this change. Sure, it's
nonstandard C/C++ code, but according to the ABI it shouldn't break.
We don't know how much code of this kind there is.
Andrew.