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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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 ` d dot ayers at inode dot at
  2003-07-31 20:26 ` pinskia at physics dot uc dot edu
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: d dot ayers at inode dot at @ 2003-07-31 20:24 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


d dot ayers at inode dot at changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |d dot ayers at inode dot at


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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-31 20:26 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


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
   Target Milestone|3.4                         |---


------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-31 20:26 -------
This also happens in "gcc version 3.3 20030304 (Apple Computer, Inc. build 1409)".

I have seen reports of this on one of the Darwin's mailing lists.


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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: zlaski at apple dot com @ 2003-07-31 20:59 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



------- Additional Comments From zlaski at apple dot com  2003-07-31 20:59 -------
Thanks for catching this.  Can you create a test case for this as well (and commit both it and the 
patch)?  Thanks.  Both the bug and the fix appear to be -fgnu-runtime specific.


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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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
                   ` (2 preceding siblings ...)
  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
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2003-07-31 21:00 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


geoffk at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |zlaski at apple dot com
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED


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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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
                   ` (3 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-07-31 22:26 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



------- Additional Comments From cvs-commit at gcc dot gnu dot org  2003-07-31 22:26 -------
Subject: Bug 11754

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	objc-improvements-branch
Changes by:	pinskia@gcc.gnu.org	2003-07-31 22:26:54

Modified files:
	gcc/objc       : objc-act.c 
Added files:
	gcc/testsuite/objc/execute: cascading-1.m 

Log message:
	Fix PR objc/11754
	When cascading message together under GNU runtime, GCC was sending the inner message twice,
	this patch fixes that.
	Also adds a testcase for that case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/objc/objc-act.c.diff?cvsroot=gcc&only_with_tag=objc-improvements-branch&r1=1.179.2.2&r2=1.179.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/objc/execute/cascading-1.m.diff?cvsroot=gcc&only_with_tag=objc-improvements-branch&r1=NONE&r2=1.1.2.1


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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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
                   ` (4 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-31 22:29 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


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-31 22:29 -------
Fixed by the patch.
Thanks for finding it alexander.


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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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
                   ` (5 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: alexander at malmberg dot org @ 2003-07-31 23:49 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


alexander at malmberg dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|FIXED                       |


------- Additional Comments From alexander at malmberg dot org  2003-07-31 23:49 -------
Unfortunately, there's a typo in the committed fix:

+      if (!supper_flag)

should be "super_flag", not "supper_flag".

Also, it's worth noting that this doesn't apply only to cascaded messages,
although that's where I discovered it. Incorrect code will be generated when the
expression for the receiver has any kind of side effect, and pessimal code in
other cases. Eg.

[SomeClass foo] would call objc_get_class("SomeClass") twice (which is harmless)

and

[someFunction() foo] would call someFunction() twice, which has a good chance of
not being harmless


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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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
                   ` (6 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-31 23:54 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



------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-31 23:54 -------
I fixed the typo.  I will also add more testcases for the tests you mentioned.


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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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
                   ` (7 preceding siblings ...)
  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
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-31 23:55 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


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-31 23:55 -------
I fixed the typo.


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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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
                   ` (8 preceding siblings ...)
  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
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-07-31 23:59 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



------- Additional Comments From cvs-commit at gcc dot gnu dot org  2003-07-31 23:59 -------
Subject: Bug 11754

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	objc-improvements-branch
Changes by:	pinskia@gcc.gnu.org	2003-07-31 23:59:04

Added files:
	gcc/testsuite/objc/execute: function-message-1.m 

Log message:
	new test case for PR objc/11754

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/objc/execute/function-message-1.m.diff?cvsroot=gcc&only_with_tag=objc-improvements-branch&r1=NONE&r2=1.1.2.1


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

* [Bug objc/11754] [objc-improvements-branch] receiver is evaluated twice when passing messages with the gnu runtime
  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
                   ` (9 preceding siblings ...)
  2003-07-31 23:59 ` cvs-commit at gcc dot gnu dot org
@ 2003-12-09 18:14 ` dhazeghi at yahoo dot com
  10 siblings, 0 replies; 12+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-12-09 18:14 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |3.4


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


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