This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug objc/11754] New: [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
- From: "alexander at malmberg dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Jul 2003 20:16:57 -0000
- Subject: [Bug objc/11754] New: [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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);