From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62632 invoked by alias); 15 Apr 2015 15:56:53 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 62320 invoked by uid 48); 15 Apr 2015 15:56:48 -0000 From: "ian at airs dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug go/65772] With multiple return values including a function with side effects, incorrect value is returned Date: Wed, 15 Apr 2015 15:56:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: go X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ian at airs dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ian at airs dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-04/txt/msg01238.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65772 Ian Lance Taylor changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #3 from Ian Lance Taylor --- The test case is invalid. It works coincidentally with gc. The order of evaluation rules for Go (http://golang.org/ref/spec#Order_of_evaluation) do not specify when a variable is read. In a case like return files, filepath.Walk(dir, visit) where files is updated by the visit function passed to filepath.Walk, the files variable may be read either before or after calling filepath.Walk. The gc compiler is generating code that reads it after, the gccgo compiler is generating code that reads it before. Either is correct according to the language spec.