public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug objc/11754] New: [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
@ 2003-07-31 20:16 alexander at malmberg dot org
  2003-07-31 20:24 ` [Bug objc/11754] " d dot ayers at inode dot at
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: alexander at malmberg dot org @ 2003-07-31 20:16 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: [objc-improvements-branch] receiver is evaluated twice
                    when passing messages with the gnu runtime
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: objc
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alexander at malmberg dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

When using the objc-improvements-branch (as of 2003-07-31) to compile for the
GNU runtime, the receiver in message calls is evaluated twice. The following
program:

<cut here>
#include <objc/Object.h>

@interface Foo : Object
+ foo;
+ bar;
@end

@implementation Foo
+ foo
{
    printf("foo\n");
    return self;
}
+ bar
{
    printf("bar\n");
    return self;
}
@end

int main(int argc,char **argv)
{
    [[Foo foo] bar];
    return 0;
}
</cut here>

prints:
""
foo
foo
bar
""
instead of the expected:
""
foo
bar
""

The following patch fixes it:

Index: gcc/objc/objc-act.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.179.2.2
diff -u -r1.179.2.2 objc-act.c
--- gcc/objc/objc-act.c 29 Jul 2003 23:01:58 -0000      1.179.2.2
+++ gcc/objc/objc-act.c 31 Jul 2003 18:51:51 -0000
@@ -6017,8 +6017,11 @@
       tree method;
 
       /* Avoid trouble since we may evaluate each of these twice.  */
-      object = save_expr (object);
+      lookup_object = save_expr (lookup_object);
       selector = save_expr (selector);
+
+      if (!super_flag)
+       object = lookup_object;
 
       lookup_object = build_c_cast (rcv_p, lookup_object);


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2003-12-09 18:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-31 20:16 [Bug objc/11754] New: [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime alexander at malmberg dot org
2003-07-31 20:24 ` [Bug objc/11754] " d dot ayers at inode dot at
2003-07-31 20:26 ` pinskia at physics dot uc dot edu
2003-07-31 20:59 ` zlaski at apple dot com
2003-07-31 21:00 ` geoffk at gcc dot gnu dot org
2003-07-31 22:26 ` cvs-commit at gcc dot gnu dot org
2003-07-31 22:29 ` pinskia at physics dot uc dot edu
2003-07-31 23:49 ` alexander at malmberg dot org
2003-07-31 23:54 ` pinskia at physics dot uc dot edu
2003-07-31 23:55 ` pinskia at physics dot uc dot edu
2003-07-31 23:59 ` cvs-commit at gcc dot gnu dot org
2003-12-09 18:14 ` dhazeghi at yahoo dot com

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