From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31723 invoked by alias); 26 Jun 2002 23:36:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 31703 invoked by uid 71); 26 Jun 2002 23:36:01 -0000 Resent-Date: 26 Jun 2002 23:36:01 -0000 Resent-Message-ID: <20020626233601.31702.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, unifex@yuidesigns.net, lindahlb@hotmail.com Resent-Reply-To: gcc-gnats@gcc.gnu.org, lindahlb@hotmail.com Received: (qmail 31021 invoked by uid 61); 26 Jun 2002 23:33:16 -0000 Message-Id: <20020626233316.31020.qmail@sources.redhat.com> Date: Wed, 26 Jun 2002 17:46:00 -0000 From: lindahlb@hotmail.com Reply-To: lindahlb@hotmail.com To: gcc-gnats@gcc.gnu.org Cc: unifex@yuidesigns.net, lindahlb@hotmail.com X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify: unifex@yuidesigns.net, lindahlb@hotmail.com Subject: c++/7135: Faulty Operator Precedence X-SW-Source: 2002-06/txt/msg00638.txt.bz2 List-Id: >Number: 7135 >Category: c++ >Synopsis: Faulty Operator Precedence >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Wed Jun 26 16:36:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Brian Lindahl >Release: 2.95.3 >Organization: >Environment: FreeBSD >Description: The source code depicting the problem is attatched as a file. Lines which show existance of the bug: cout << a.set(5).get() << a.set(30).get(); cout << a.get(); The output of the compiled program: 5305 The machine code appears to be executeing 'set(5)' first, and then 'set(30)', as it should. However, as indicated by the last output, it executed 'set(5)' last as well as first. It appears to be executing 'set(5)' twice. The generated code should be of the following: operator<<(operator<<(cout, a.set(5).get()), a.set(30).get()); I ran over the output and code several times to figure out what order the operations are actually taking place, but I was unable to come up with a logical order that would produce the output, unless 'set(5)' was being executed twice. >How-To-Repeat: The file attatched shows how to repeat. >Fix: There are two fixes: 1) Adjust the problem lines as so: cout << a.set(5).get(); cout << a.set(30).get(); cout << a.get(); 2) Inline the methods 'set(int)' and 'get()' Apply either fix and the output of the compiled program is as expected: 53030 >Release-Note: >Audit-Trail: >Unformatted: