public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug objc/36610]  New: message forwarding broken on x86_64: self is not receiver
@ 2008-06-24  1:48 hydrologiccycle at gmail dot com
  2008-06-24  1:53 ` [Bug libobjc/36610] " pinskia at gcc dot gnu dot org
                   ` (16 more replies)
  0 siblings, 17 replies; 27+ messages in thread
From: hydrologiccycle at gmail dot com @ 2008-06-24  1:48 UTC (permalink / raw)
  To: gcc-bugs

Note that this is a 64-bit problem.  i386 works fine.  Code for reproducing is
included, as well as all system information.


correct output of program on 32-bit:

forwarding for selector display from 134536384 to 134536136
worked, self == receiver
foo is 1234567890, and should be 1234567890


incorrect output of program on 64-bit:

forwarding for selector display from 6330720 to 6330224
broken, self != receiver
foo is 6330224, and should be 1234567890


test program:

// Objective-C x86_64 bug:  self is wrong on forward;
// broken on gcc-4.1.2, 4.3.0, and 4.3.1

#include <stdio.h>
#include <stdlib.h>
#include <objc/Object.h>
#include <objc/objc-api.h>

id forwarder, receiver;

@interface Forwarder:Object
{
    id receiver;
}

-initWithReceiver:theReceiver;

@end

@interface Receiver:Object
{
    int foo;
}

-display;
-initWithFoo:(int)theFoo;

@end

@implementation Receiver

-initWithFoo:(int)theFoo
{
    foo = theFoo;
    return self;
}

-display
{
    if (self == receiver) {
        printf("worked, self == receiver\n");
    } else {
        printf("broken, self != receiver\n");
    }
    printf("foo is %d, and should be %d\n", foo, 1234567890);
    return self;
}

@end

@implementation Forwarder

-initWithReceiver:theReceiver
{
    [super init];
    receiver = theReceiver;
    return self;
}

-(retval_t) forward:(SEL)theSel:(arglist_t)theArgFrame
{
    if (receiver) {

        printf("forwarding for selector %s from %ld to %ld\n",
            sel_get_name(theSel), self, receiver);

        //return objc_msg_sendv(itsNextLink, theSel, theArgFrame);
        return [receiver performv:theSel:theArgFrame];

    } else {
        return [self doesNotRecognize:theSel];
    }
}

@end

int main()
{
    receiver = [[Receiver alloc] initWithFoo:1234567890];
    forwarder = [[Forwarder alloc] initWithReceiver:receiver];

    [forwarder display];

    exit(EXIT_SUCCESS);
    return 0;
}


I compiled gcc from the 4.3.1 tarball on ftp.gnu.org in order to avoid any
distro patches.  Here's the output of gcc -v:

Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-4.3.1/configure --prefix=/usr/local
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--enable-nls -
-without-included-gettext --with-system-zlib --disable-checking
--disable-werror --enable-secureplt --disable-multilib --enable-libmudflap
--disabl
e-libssp --disable-libgcj --enable-languages=c,objc --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu             
Thread model: posix
gcc version 4.3.1 (GCC)


-- 
           Summary: message forwarding broken on x86_64: self is not
                    receiver
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: objc
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hydrologiccycle at gmail dot com
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 27+ messages in thread
[parent not found: <bug-36610-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2011-06-30 10:05 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-24  1:48 [Bug objc/36610] New: message forwarding broken on x86_64: self is not receiver hydrologiccycle at gmail dot com
2008-06-24  1:53 ` [Bug libobjc/36610] " pinskia at gcc dot gnu dot org
2008-12-29  2:19 ` pinskia at gcc dot gnu dot org
2009-01-01 16:24 ` pinskia at gcc dot gnu dot org
2009-01-01 16:26 ` [Bug middle-end/36610] __builtin_apply is broken for targets which pass argument via registers pinskia at gcc dot gnu dot org
2009-01-01 16:27 ` hjl dot tools at gmail dot com
2009-02-12 11:32 ` [Bug objc/36610] objc_msg_sendv " matz at gcc dot gnu dot org
2009-03-27 16:52 ` ghazi at gcc dot gnu dot org
2009-03-27 16:55 ` ghazi at gcc dot gnu dot org
2009-03-27 17:38 ` dave at hiauly1 dot hia dot nrc dot ca
2009-03-31 19:12 ` ghazi at gcc dot gnu dot org
2009-03-31 19:34 ` [Bug libobjc/36610] " pinskia at gcc dot gnu dot org
2009-03-31 20:28 ` janis at gcc dot gnu dot org
2009-04-09 16:59 ` janis at gcc dot gnu dot org
2009-04-09 17:02 ` janis at gcc dot gnu dot org
2009-04-19 15:52 ` pinskia at gcc dot gnu dot org
2010-02-24 11:56 ` ro at gcc dot gnu dot org
2010-06-02 17:17 ` ro at gcc dot gnu dot org
     [not found] <bug-36610-4@http.gcc.gnu.org/bugzilla/>
2010-11-07 14:50 ` iains at gcc dot gnu.org
2010-11-07 19:02 ` pinskia at gcc dot gnu.org
2010-11-07 19:55 ` iains at gcc dot gnu.org
2011-06-14 13:54 ` ro at CeBiTec dot Uni-Bielefeld.DE
2011-06-14 14:02 ` js-gcc at webkeks dot org
2011-06-14 18:29 ` nicola at gcc dot gnu.org
2011-06-17 13:25 ` ro at CeBiTec dot Uni-Bielefeld.DE
2011-06-17 13:29 ` dominiq at lps dot ens.fr
2011-06-30 10:05 ` ro at gcc dot gnu.org

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).