From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3314 invoked by alias); 12 Apr 2002 13:26:07 -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 3239 invoked by uid 71); 12 Apr 2002 13:26:03 -0000 Resent-Date: 12 Apr 2002 13:26:03 -0000 Resent-Message-ID: <20020412132603.3236.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 Resent-Reply-To: gcc-gnats@gcc.gnu.org, mantonenco@yahoo.com Received:(qmail 32002 invoked by uid 61); 12 Apr 2002 13:19:18 -0000 Message-Id:<20020412131917.32000.qmail@sources.redhat.com> Date: Fri, 12 Apr 2002 06:26:00 -0000 From: mantonenco@yahoo.com Reply-To: mantonenco@yahoo.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/6272: GCC 2.95 fail X-SW-Source: 2002-04/txt/msg00652.txt.bz2 List-Id: >Number: 6272 >Category: c++ >Synopsis: GCC 2.95 fail >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Apr 12 06:26:02 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Antonenco Mihai >Release: gcc version 2.95.2 19991024 (release) >Organization: >Environment: Suse 7.3 >Description: mantonenco@linux1:/home/mantonenco/work/Test > gcc linuxProblem.cpp linuxProblem.cpp: In function `int main()': linuxProblem.cpp:23: initialization of non-const reference type `struct A &' linuxProblem.cpp:23: from rvalue of type `A' linuxProblem.cpp:10: in passing argument 1 of `A::operator =(A &)' >How-To-Repeat: // I had this problem when I worked with auto_ptr // and tried to make a resource transfer: ptr = f() // The solution that I was forced to use was: // auto_ptr tempPtr = f(); // ptr = tempPtr; // This solution doesn'd look good ! struct A { A& operator=(A& a) { return *this; }; }; A f() { A a; return a; }; int main() { A a; a = f(); return 0; }; >Fix: I had to replace in my code: ptr = f(); with auto_ptr tempPtr = f(); ptr = tempPtr; >Release-Note: >Audit-Trail: >Unformatted: