This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/3230: False warning for 'returning reference to temporary'
- From: Gabriel Dos Reis <gdr at codesourcery dot com>
- To: jason at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 21 Mar 2002 08:26:01 -0000
- Subject: Re: c++/3230: False warning for 'returning reference to temporary'
- Reply-to: Gabriel Dos Reis <gdr at codesourcery dot com>
The following reply was made to PR c++/3230; it has been noted by GNATS.
From: Gabriel Dos Reis <gdr@codesourcery.com>
To: jason@gcc.gnu.org
Cc: andrewp@andypo.net, gcc-bugs@gcc.gnu.org, gdr@gcc.gnu.org,
gcc-gnats@gcc.gnu.org
Subject: Re: c++/3230: False warning for 'returning reference to temporary'
Date: 21 Mar 2002 09:17:51 +0100
jason@gcc.gnu.org writes:
| Synopsis: False warning for 'returning reference to temporary'
|
| Responsible-Changed-From-To: gdr->jason
| Responsible-Changed-By: jason
| Responsible-Changed-When: Mon Mar 18 06:02:19 2002
| Responsible-Changed-Why:
| mine
| State-Changed-From-To: analyzed->closed
| State-Changed-By: jason
| State-Changed-When: Mon Mar 18 06:02:19 2002
| State-Changed-Why:
| This is not a bug in the compiler. The standard (5.16) says that the result of your ?: expression is an rvalue, because the two options do not have the same type. As a result, the return value binds to that rvalue, which is a local temporary. The EDG compiler gives the same warning.
OK.
| You may feel that this is a bug in the standard, and I'd be
| inclined to agree. But until the standard is fixed, the compiler will
| continue to work this way.
I'll raise the issue on the core group refelector.
-- Gaby