public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/6271: GCC 2.95 fail
@ 2002-04-12 18:34 rodrigc
  0 siblings, 0 replies; 2+ messages in thread
From: rodrigc @ 2002-04-12 18:34 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, mantonenco, nobody

Synopsis: GCC 2.95 fail

State-Changed-From-To: open->closed
State-Changed-By: rodrigc
State-Changed-When: Fri Apr 12 18:34:51 2002
State-Changed-Why:
    Your code is buggy, not gcc.
    Compiling with the Digital Unix C++ compiler shows:
    
    cxx: Warning: a.cpp, line 23: initial value of reference to non-const
    must be
              an lvalue
            a = f();
    ------------^
    
    
    
    
    
    
    For general C++ help, refer to the comp.lang.c++ or
    comp.lang.c++.moderated newsgroups.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6271


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

* c++/6271: GCC 2.95 fail
@ 2002-04-12  6:26 mantonenco
  0 siblings, 0 replies; 2+ messages in thread
From: mantonenco @ 2002-04-12  6:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         6271
>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:01 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<AType>
// and tried to make a resource transfer: ptr = f()
// The solution that I was forced to use was:
// auto_ptr<AType> 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<AType> tempPtr = f();
   ptr = tempPtr;
>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2002-04-13  1:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-12 18:34 c++/6271: GCC 2.95 fail rodrigc
  -- strict thread matches above, loose matches on Subject: below --
2002-04-12  6:26 mantonenco

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