Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How should integer return value should be extended?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post will appear after it is approved by moderators
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michael Matz  
View profile  
 More options Jul 24 2007, 11:04 am
From: Michael Matz <m...@suse.de>
Date: Tue, 24 Jul 2007 17:04:48 +0200 (CEST)
Local: Tues, Jul 24 2007 11:04 am
Subject: Re: How should integer return value should be extended?
Hi,

On Tue, 24 Jul 2007, hong...@gmail.com wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32843

> it seems that ia32 psABI doesn't specify how an integer return value
> should be extended. For
> example,

> signed char
> return_sc (signed char *sc)
> {
>   return *sc;
> }

> The return value is in eax. Should it be sign extended or zero
> extended?

I actually think it shouldn't matter.  The caller should only rely on the
parts of %eax which are covered by the return type.

So problems can only arise if the caller for some reason doesn't know the
exact return type (like in the bugreport the ffi library, which simply
assumes that the return type is ffi_arg).  If we want to define something
for that case (I think outside the C standard, but the ABI doesn't need to
confine itself to only valid programs), then we can't specify either sign
or zero extension exclusively, as the extension needs to be value
preserving.

Hence I think we can only say that before returning, %eax should be sign
extended when the actual return type was a signed one, or zero extended if
not.  I don't think we should go that route, though.

Ciao,
Michael.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.