public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/32843] [4.3 Regression] : libffi.call/return_sc.c
Date: Tue, 24 Jul 2007 10:11:00 -0000	[thread overview]
Message-ID: <20070724101106.6904.qmail@sourceware.org> (raw)
In-Reply-To: <bug-32843-682@http.gcc.gnu.org/bugzilla/>



------- Comment #1 from rguenth at gcc dot gnu dot org  2007-07-24 10:11 -------
The problem seems to be a backend one(?).  What happens is that for

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

the return value is now zero-extended instead of sign-extended (the sign
extension was done in the C frontend code).  The C standard in 6.8.6.4
specifies that for the return statement _only_ if the expression has
a different type from the return type of the function then
'the value is converted as if by assignment to an object having the return
type of the function'.  Which reading either way doesn't specify whether
the return value is implicitly sign-extended or not (AFAIK whether in
this case the value is sign or zero extended should be / is specified by the
target ABI).

On x86_64 we get

return_sc:
.LFB12:
        movl    %edi, %eax
        ret

...
        movl    $-127, %edi
        call    return_sc

which is why we may be lucky here(?).  On i686 we pass on the stack like

return_sc:
        pushl   %ebp
        movl    %esp, %ebp
        movzbl  8(%ebp), %eax
        popl    %ebp
        ret

...
        movl    $-127, (%esp)
        call    return_sc

explicitly doing zero-extension.  Now the libffi testcase explicitly checks
for sign-extension(!) of the return value:

  for (sc = (signed char) -127;
       sc < (signed char) 127; sc++)
    {
      ffi_call(&cif, FFI_FN(return_sc), &rint, values);
      CHECK(rint == (ffi_arg) sc);
    }

as rint is of type ffi_arg (unsigned long) and sc is signed char.  I wonder
whether this is desired or not.  Andreas?

Micha, how is promotion of the return value specified in the x86 ABI?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matz at suse dot de,
                   |                            |andreast at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32843


  parent reply	other threads:[~2007-07-24 10:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-21  6:35 [Bug c/32843] New: " hjl at lucon dot org
2007-07-21  8:34 ` [Bug c/32843] " pinskia at gcc dot gnu dot org
2007-07-24 10:11 ` rguenth at gcc dot gnu dot org [this message]
2007-07-24 10:13 ` rguenth at gcc dot gnu dot org
2007-07-24 10:25 ` [Bug testsuite/32843] " rguenth at gcc dot gnu dot org
2007-07-24 10:27 ` rguenth at gcc dot gnu dot org
2007-07-24 11:47 ` rguenth at gcc dot gnu dot org
2007-07-25 20:11 ` andreast at gcc dot gnu dot org
2007-07-26  9:14 ` rguenth at gcc dot gnu dot org
2007-07-26  9:14 ` rguenth at gcc dot gnu dot org
2007-07-26  9:25 ` jakub at gcc dot gnu dot org
2007-07-26 10:01 ` rguenth at gcc dot gnu dot org
2007-07-31 15:06 ` aph at gcc dot gnu dot org
2007-08-06 12:48 ` aph at gcc dot gnu dot org
2007-08-06 12:53 ` aph at gcc dot gnu dot org
2007-08-06 13:35 ` aph at gcc dot gnu dot org
2007-08-06 20:13 ` doko at gcc dot gnu dot org
2008-01-02 22:59 ` andreast at gcc dot gnu dot org
2008-01-05 21:32 ` andreast at gcc dot gnu dot org
2009-09-17 20:55 ` ljrittle at gcc dot gnu dot org
2010-06-20 17:12 ` gerald at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070724101106.6904.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).